Post by jarychk on Jul 17, 2024 21:03:02 GMT
Another programming exercise using flag variables for opened windows. This lets the user keep busy until closing the main program window. All three are the same size so need to move one out of the way to reach the main window, like to close it (and the program).
flag2a=0
flag2b=0
nomainwin
WindowWidth = 550
WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
button #main.busy, "Let's get busy", [busy], UL, 206, 156, 144, 40
open "two windows each with own flag" for window as #main
print #main, "trapclose [quit.main]"
print #main, "font ms_sans_serif 10"
wait
[quit.main]
'in case either lower window is open
'must first close them
if flag2a=1 then close #altern
if flag2b=1 then close #stbusy
Close #main
END
[busy] 'using flag2a
if flag2b=1 then
close #stbusy
flag2b=0
end if
nomainwin
WindowWidth = 550
WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
button #altern.results, "go to results", [goresults], UL, 222, 281, 144, 45
open "point to results" for window as #altern
print #altern, "trapclose [quit.altern]"
print #altern, "font ms_sans_serif 10"
let flag2a=1
wait
[quit.altern]
Close #altern
flag2a=0
wait
[goresults] 'using flag2b
if flag2a=1 then
close #altern
flag2a=0
end if
nomainwin
WindowWidth = 550
WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
button #stbusy.stbusy, "staying busy", [busy], UL, 174, 66, 152, 40
open "staying busy" for window as #stbusy
print #stbusy, "trapclose [quit.stbusy]"
print #stbusy, "font ms_sans_serif 10"
let flag2b=1
wait
[quit.stbusy]
Close #stbusy
flag2b=0
wait