Description
- Halts program execution and waits for a user action. Also used with the timer statement to wait for the timer to fire.
- See also TIMER.
Syntax
- wait
Hints
- When a branch or routine does not return upon completion to the place in the code where it was initially called, the WAIT command will prevent the code from "falling through" and executing the next branch or line of code - unless, of course, that is what you want the program to do.
- If using WAIT inside a sub or a function, be sure that any action the user may take after the WAIT can be handled from within the routine, and the END SUB (or END FUNCTION) statement can be executed. This will enable the program to return to where the procedure was called.
Example
' This example shows the use of WAIT to halt program execution,
' and also to WAIT for the Windows timer to tick down.
nomainwin
button #1.btn, "OK!", [quit], UL, 125, 100
statictext #1.st, "", 85, 150, 150, 35
open "Waiting for user action..." for window as #1
#1 "trapclose [quit]"
[begin]
' Wait here until user clicks button
#1.st "Press OK when ready."; chr$(13);_
wait
[quit]
' Wait 2 seconds before closing
timer 2000, [done]
#1.st "Give me a couple seconds..."; chr$(13);_
"Closing, 1, 2, 3..."
wait
[done]
timer 0
close #1
end
Useful Procedures
' Place a useful function or sub using this keyword here