A Schedule() function lets you set up a script to be executed some number of seconds later.
Schedule( 15, Print( "hello" ) );
Scheduled at 11.55000000000018 :Print("hello")
Scheduled at 4.716666666666697 :Print("hello")
Scheduled at 3.083333333333485 :Print("hello")
quickieScript = Expr(
Show( "Hi there" );
Schedule( 15, quickieScript );
);
quickieScript;
FifteenMinuteCheck = Expr(
Show( "Checking data" );
Open( "my file", options... );
distribution( Column( column1 ), capability( spec limits ) );
Schedule( 15 * 60, FifteenMinuteCheck );
);
FifteenMinuteCheck;
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:
Schedule( 3, Print( "one" ) );
Print( "two" );
"two"
"one"
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:
Schedule( 3, Print( "hello" ) );
Schedule( 4, Print( ", world" ) );
Schedule( 5, Print( "--bye" ) );
To cancel all events in a schedule queue, use Clear Schedule.
scheduler[1] << Clear Schedule( );
Note: It is not possible to create multiple threads using Schedule.
Schedule |
sc=Schedule(n, script) |
|
Clear Schedule |
sc<<Clear Schedule()
|