Index

schedule filename(arguments)

Add a schedule to the list of pending schedules.

Arguments:
Script filename(arguments)
The path-name and arguments of the scheduling script to be queued.

Example:
The following example adds a file called observe.sch from the home directory of a user called mcs to the queue of schedules waiting to be run. If the script is ok, and no other schedules are waiting to run, then it will be run immediately. This script doesn't expect any arguments, so the parentheses that normally enclose the argument list have been omitted.
 schedule ~mcs/observe.sch
Example of using arguments:
One can also pass arguments to scheduling scripts. These should be constant expressions that don't include either references to variables or function calls. A scheduling script accepts arguments if the first line of the script contains their declarations, enclosed in parentheses. For example, to create a script that takes a String argument and a Boolean argument, the first line of the script would be something like the following:
 (String s, Boolean b)
 ...statements...
Thereafter s and b behave like global variables with constant values.

The corresponding script, say ~mcs/test.sch would then be scheduled by typing:

  schedule ~mcs/test.sch("hello", true)
If one were to call the script without any arguments, an error message would be emitted.

An interesting use of schedule arguments is to pass the name(s) of files to import statements. This allows one to create a template schedules which operate on lists of values provided by imported files. An example of this is given in the documentation of the Script command, where a list of stars to be observed is passed to the script by way of a file that the script imports. The imported file declares and defines a list variable of sources, giving it the name expected by the foreach statement that follows the import statement.

Context:
When a script is scheduled for execution, it is first compiled by the scheduler. This has the side effect of checking the script for errors. If it gets through the compiler without any errors, then it gets added to the end of the queue of scripts that are pending to be run. After this point the script file can be discarded or changed without effecting the compiled form of the script. While the real-time control system is running, the script at the front of the queue runs to completion. If the real-time control system goes down, for any reason, the script at the font of the queue is rewound to its start and returned to a pending state. It is then restarted when the control-system comes back on line. Once the script at the front of the queue has run to completion, or been aborted with the abort_schedule command, the next schedule on the queue is started.

Martin Shepherd (31-Oct-1999)