Menu

scScript Script Package

The Script package is used to load and execute sub-scripts from a running script. These were initially designed for system testing and validation, but seem to have acquired a life of their own. Since a sub-script can in turn load and execute other scripts, there can be a hierarchy of running scripts at a given time. This package also has a few helper functions for traversing the script hierarchy and getting parameters, such as Id and Level.

Note: Level indicates the position of the script in the running hierarchy, it is meaningless for a non running script.

Functions:
Self
Sc = Script.Self();
Returns the current running Script (obviously to itself).
Sup
SupSc = Script.Sup(Sc);
Returns the superior script of the (optional) Sc script, Int 0 if none.
If no Sc, then the superior of the currently running script.
Note: Only the current script can have a superior.
Id
X = Script.Id(Sc);
Returns id number of the (optional) Sc script.
If no Sc, then the id of the currently running script.
Level
X = Script.Level(Sc);
Returns level number of the (optional) Sc script.
If no Sc, then the level of the currently running script.
Load
Sc = Script.Load(FStr);
Read and load the specified script file (FStr) into a var.
FStr (required) may include path specifications for .sc or .bsc script.
Latter are immediately loaded while former are compiled first.
Exec
X = Script.Exec(Sc);
Executes the script loaded into the required Sc var and returns result.
(Most scripts end without an explicit Return, so the result is 0).

Note: Script.Exec will happily execute its own script (from Script.Self()) or even a superior one (from Script.Sup(Sc)). In fact, it clones the running script, behind the scenes, so it can execute it, without forming a circular superior chain, for the very rare circumstances where this is required. But a script executing itself or a superior is usually a very bad idea and a good way to get super confused!