A Schedule function lets you set up a script to be executed some number of seconds later.
A Scheduler window shows the time until the next event and has buttons for restarting (Go) or stopping (Stop) the schedule. Its pop-up menu has a command Show Schedule, which echoes the current schedule to the log. For example, if you checked the schedule several times during the “hello” example, you would see something like this:
This script should show the string “Hi there” in a log window after 15 seconds, and reschedule itself for another 15 seconds, continuing until the Stop button is clicked.
Schedule initiates an event queue, but once it has the event queued, JMP proceeds with the next statement in the script. For example, the following has results that might surprise you:
If you want the script to wait until the scheduled events are finished before proceeding, one solution would be to use Wait( ) with a suitable pause. Another is to embed the subsequent actions into the schedule queue. Schedule accepts a series of arguments to queue many events in sequence. Each event is a separate call to the schedule. Each event time is an absolute time relative to “now” (or the instant that Go is clicked). Therefore, the following sequence finishes in five seconds, not in twelve:
To cancel all events in a schedule queue, use Clear Schedule.
Note: It is not possible to create multiple threads using Schedule.
sc<<Clear Schedule( )
|