Post by Chris Iverson on Aug 29, 2019 11:45:44 GMT -5
This is another bug I found while attempting to debug my program.
This is in LB5-350, confirmed on Windows, will confirm other platforms later.
Basically, if you have a conditional that executes a wait statement before the end of a branch label, the next event will cause execution to continue from the conditional, not from the proper branch label event handler.
With this code, as written, the condition in the Button1 handler will be false, and execution will go to "After stopEvent" when you click Button1. If you then click Button2, it will run Button2's event handler, and print "Button 2 clicked", as expected.
Next, edit the code to change stopEvent to 1. Then click Button1. This time, the condition is true, and execution will go to print "stopping event early", and then wait. This is as expected.
If you then click Button 2, instead of going to the Button 2 event handler, execution will continue to the line 'print "After stopEvent"'.
This is in LB5-350, confirmed on Windows, will confirm other platforms later.
Basically, if you have a conditional that executes a wait statement before the end of a branch label, the next event will cause execution to continue from the conditional, not from the proper branch label event handler.
'Form created with the help of Freeform 3 v07-15-08
'Generated on Aug 29, 2019 at 11:36:04
[setup.main.Window]
'-----Begin code for #main
'nomainwin
WindowWidth = 550
WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
'-----Begin GUI objects code
button #main.button1,"Button 1",[button1Click], UL, 30, 22, 96, 25
button #main.button2,"Button 2",[button2Click], UL, 35, 82, 96, 25
'-----End GUI objects code
open "untitled" for window as #main
print #main, "font ms_sans_serif 10"
print #main, "trapclose [quit.main]"
[main.inputLoop] 'wait here for input event
stopEvent = 1
wait
[button1Click] 'Perform action for the button named 'button1'
'Insert your own code here
if stopEvent = 1 then
print "stopping event early."
wait
end if
print "After stopEvent."
wait
[button2Click] 'Perform action for the button named 'button2'
'Insert your own code here
print "Button 2 clicked"
wait
[quit.main] 'End the program
close #main
end
With this code, as written, the condition in the Button1 handler will be false, and execution will go to "After stopEvent" when you click Button1. If you then click Button2, it will run Button2's event handler, and print "Button 2 clicked", as expected.
Next, edit the code to change stopEvent to 1. Then click Button1. This time, the condition is true, and execution will go to print "stopping event early", and then wait. This is as expected.
If you then click Button 2, instead of going to the Button 2 event handler, execution will continue to the line 'print "After stopEvent"'.