Execution can 'fall through' a WAIT

From Liberty BASIC Family
Jump to navigation Jump to search

Description

When a WAIT statement is executed, Liberty BASIC should pause until an event (such as a button press or a timer interrupt) occurs. At that time execution should either jump to the specified place (in the case of a [branchLabel] handler) or the specified subroutine should be called (in the case of a subName handler). Under no circumstances should execution fall through the WAIT statement to the next and subsequent lines, but in LB 4.04 and LB 4.5.0 that is what happens if the third kind of handler (returnVar string) is specified.

Example code to demonstrate the bug.

Click the button and see what happens in the mainwin:

    button #w, "Click me", returnVar, UL, 100, 100
    open "Event bug" for window as #w
    wait
    print "Fell through a WAIT statement!!"

[label1]
    print "Execution continues at label1"
    wait
    print "Fell through a WAIT statement!!"

[label2]
    print "Execution continues at label2"
    wait
    print "Fell through a WAIT statement!!"

Example code to work around the bug.

Since this bug is present whether the programmer uses a branch label or subroutine, the programmer should actually define the branch label or subroutine used within the code.