Sleep
Synchronization function.
The Sleep function makes the current script "sleep" while leaving event handlers active. Not available in WinTask Lite.
Syntax
Sleep()
Parameters
None.
Remarks
The script is inactive but the events are still managed.
If a script launches another script using the RUN function, the parent script is "sleeping" until the child script returns control.
A "sleeping" script is ended inside a sub-routine associated with an event handler, through a STOP or END statement, or in another script by the STOP statement.
Example code
This example shows how the Sleep command is used in order to make the event handler defined by OnAction remain active.
Sub close()
Disable(wait_close_menu)
res=msgbox("Would you like to close the message box? ",4,"EXAMPLE")
if res=6 then
' if res=6 WinTask closes Explorer and stops the script
CloseWindow("EXPLORER.EXE|ExploreWClass|My Documents",1)
stop
endif
enable(wait_close_menu)
EndSub
shell("explorer")
' Definition of the event handler
' each time the user selects the Close option from the Explorer menu File,
' the script executes the close() function.
OnAction wait_close_menu
Menu("&File|&Close")
InWindow("EXPLORER.EXE|ExploreWClass|My Documents",1)
DoSub close
EndAction
sleep()
'leaves the event handler active.