NSB.MsgBox() not showing up

I have some simple POC code - the message boxes never show up. If replaced with alert()'s - no problem. Is there some kind of a delay with the message boxes? Can they be ‘made’ to work (since alerts are so ugly)? Thanks -

function getRandom(max,min) {
    return parseInt(Math.random() * (max - min) + min)
}

var cont = true
var number = 0
while (cont == true) {
    number = getRandom(20,1)
    console.log("Random number: " + number)
    var guess = + prompt("Guess a number between 1 and 20")
    if (guess == number) {
        NSB.MsgBox("You are right!",0,"Response")
        console.log("guess is : " + guess + " and you are right!")
    } else
        NSB.MsgBox("You are wrong",0,"Response")
    cont = confirm("Do you want to continue?")
 }

NSB.MsgBox is asynchronous - execution continues while it is displayed.
https://wiki.nsbasic.com/NSB.MsgBox

In this case, the NSB.MsgBox is executed - but execution doesn’t stop while waiting for the user. The program goes straight on to the confirm() statement, then back to the top of the loop.

If you want to stop execution, use the callback parameter and continue execution there.

I don’t know what the callback parameter is - can you direct me to some documentation? Thanks -

Cindy

The wiki has it, along with sample code:

https://wiki.nsbasic.com/NSB.MsgBox

See Buttons 3, 4 and 6.

1 Like