Recording an SCL script
To record an SCL script choose the MACRO RECORD START function.
This can be found on the toolbar by pressing the
button.
To record a script you must give a name for the script file that will be created. All scripts are created with the .tcl extension.
During recording, the recording indicator presents a blinking icon
to give positive feedback of recording in progress.
To finish recording the MACRO RECORD END function must be executed.
This function can be executed by pressing the
icon. An alternate method to stop recording is to exit the software.
Recorded events
After commencing to record a script all recordable events will be recorded in the script file to permit immediate playback after terminating the recording session.
Not all actions that are performed are recorded to the script file. In general, only actions that cause a permanent change to occur are recorded. For example, navigating the menu hierarchy, displaying and undisplaying menus bars and toolbars are events that are not recorded. Similarly, movement of the mouse over the graphics window is not recorded, nor are mouse events for the dynamic viewer function that uses the mouse to rotate, scale, etc. the view. These events are not recorded because they serve no perpose in automating the processing of data. If these events were recorded they would result in extraordinarily huge script files.
Consequently, events that have some tangible effect on data are recorded. Such events include:
- Functions that have inputs and produce outputs
- Graphics functons for digitising or selecting locations
- Viewing functions that have a one-off effect on the view. i.e. WINDOW IN/OUT, ZOOM IN/OUT, etc.
A sample script
A simple script that has been created by recording the RECALL FILE function is shown below. The RECALL FILE function loads a file and displays the data in the file in a 3D graphics window.
| Simple recorded script |
|---|
set status [ SclFunction "RECALL FILE" {
frm00236={
{
location="D:\\sv32\\dem\\training\\intro\\pit"
rid="1"
string_rng=""
ftype="S"
swa_desc="Y"
append="R"
styles_file="SSI_STYLES:styles.ssi"
rescale="Y"
swa_name="main graphics layer"
_action="Apply"
}
}
}]
|
Note that field values containing the TCL special characters described in An Introduction to Tcl Syntax will have these characters replaced by codes:
| TCL Special Character |
Code |
| " | \042 |
| $ | \044 |
| [ | \133 |
| ] | \135 |
| { | \173 |
| } | \175 |
Using data dependent values for parameters
Some detailed knowledge of the parameters for the RECALL FILE function is required for the following explanation to make sense. Some function parameters have values that are dependent on the file or data being processed. In the example shown above, the styles_file parameter has a value of SSI_STYLES:styles.ssi. This value has been determined by the programme obtaining the name of the styles file from the string file header. This value is then of course displayed oin the form while the script is being recorded and of course it is also recorded in the script.
During script execution, it is sometimes preferable to have values for parameters such as this determined by the programme rather than by using the values recorded in the script. The styles_file parameter is a good example of this requirement. By removing the name of the styles file from the script the programme will always use the data dependent value rather than the recorded value.
This is easily achieved and the best way to explain is by example. A suitably modified script is shown below.
| Script with modifications to use data dependent value |
|---|
set status [ SclFunction "RECALL FILE" {
frm00236={
{
location="D:\\sv32\\dem\\training\\intro\\pit"
rid="1"
string_rng=""
ftype="S"
swa_desc="Y"
append="R"
rescale="Y"
swa_name="main graphics layer"
_action="Apply"
}
}
}]
|
In this example note how the styles_file parameter has been removed from the script. This ensures that the value for this parameter is determined by the data being processed and that it behaves just as it would if executing the function interactively.
The swa_name parameter determines the Graphics layer into which the data is loaded. The value for this parameter is determined by the active layer that can be set using either the SELECT LAYER or LAYERS functions. With the value for this parameter recorded in the script as it is, during script playback a layer called main graphics layer will be created if it does not already exist.
This may be desirable but then it may not. Whether this is acceptable behaviour is dependent upon your needs. By removing the swa_name parameter from the script completely the active layer name will be used even during script execution.
Identifying such data dependent parameters requires that you identify those parameters whose values are determined by means other than direct keyboard entry. Whether these parameters should be removed from the script prior to execution or not depends entirely on the requirements for the script. As a general rule though, removal of these parameters will give more desireable results during script execution since the data dependent values for these parameters will be used as they are not explicitly defined in the script.