06-05-2023, 09:04 PM
The easiest way to use _EXIT, is just like the following:
Code: (Select All)
_Title "_Exit Demo by Steve"
Dim Shared a As _Integer64
If _Exit Then System 'If you've clicked the exit button before we've did
' anything more than display a screen and a title,
' let's just give up and quit early and call it a day!
' The whole point to this early call to _EXIT is to disable the auto-exit and just
'to let our program know that we're going to manually be checking for it from now on.
Do 'a main loop to do whatever we want
Cls
a = a + 1
Print "Whee! I'm ah counting! "; a
_Limit 100 'I'm going to count 100 counts per second.
If _Exit Then Shutdown 'Here we check our exit flag and if it's called, we jump to the shutdown routine.
Loop 'and I'm going to run forever and ever and ever and ever (as long as no one exits the program)
Sub Shutdown
Print
Print "Oh nos! You have found my weakness and shut me down after I have ah only counted ta"; a
a$ = "This is the end of ah me!"
For i = 1 To Len(a$)
Print Mid$(a$, i, 1); "..";
_Delay .2
Next
_Delay 2
Beep
Print "And now I is ended!"
System
End Sub