Section 10: Instrument programming Model 2601B-PULSE System SourceMeter Instrument Reference Manual
10-36 2601B-PULSE-901-01A April 2020
Advanced scripting for TSP
The following topics describe advanced information that can help you understand how the Test Script
Processor (TSP
®
) scripting engine works.
Global variables and the script.user.scripts table
When working with script commands, it is helpful to understand how scripts are handled in
the instrument.
Scripts are loaded into the runtime environment from nonvolatile memory when you turn the
instrument on. They are also added to the runtime environment when you load them into
the instrument.
A script in the runtime environment can be:
• A named script
• An unnamed script
• The anonymous script (which is a special unnamed script)
Script names can be assigned by using the loadscript command or by defining the scriptVar
parameter of the script.new() function. When a named script is loaded into the
runtime environment:
• A global variable with the same name is created so that you can reference the script
more conveniently.
• An entry for the script is added to the script.user.scripts table.
When you create a script using the script.new() function without providing a name, the script is
added to the runtime environment as an unnamed script. The script.new() function returns the
script, but the script is not added to the script.user.scripts table.
When the anonymous script is loaded, it does not have a global variable or an entry in the
script.user.scripts table. If there is an existing anonymous script, it is replaced by the
new one.
When the instrument is turned off, everything in the runtime environment is deleted, including the
scripts and global variables.
See the figure below to see how the scripts, global variables, and script.user.scripts
table interrelate.