2606B System SourceMeter® Instrument Reference Manual
Section 6: Instrument programming
2606B-901-01 Rev. B / May 2018
6-5
To load a named script by sending commands:
1. Send the command
loadscript
scriptName
, where
scriptName
is the name of the script.
The name must be a legal Lua variable name.
2. Send the commands that need to be included in the script.
3. Send the command
endscript
.
4. You can now run the script. See
(on page 6-7).
To run the script immediately, use
loadandrunscript
scriptName
instead of
loadscript
.
Create a script using TSB Embedded
If you are using TSB Embedded to create scripts, you do not need to use the commands
loadscript
or
loadandrunscript
and
endscript
.
You can create a script from the instrument web page with TSB Embedded. When you save the script
in TSB Embedded, it is loaded into the run-time environment and saved in the nonvolatile memory of
the instrument.
To create a script using TSB Embedded:
1. In the TSP Script box, enter a name for the script.
2. In the input area, enter the sequence of commands to be included in the script.
3. Click
Save Script
. The name is added to the User Scripts list on the left.
Load a script from the instrument front panel
You can also load scripts from a USB flash drive to the run-time environment of the instrument.
Depending on the content of the TSP file on the drive, the script can be loaded either as an
anonymous script without a designated name, or as a named script with a user-defined name. Only
named scripts can be saved to internal nonvolatile memory. Only one anonymous script can exist in
the run-time environment.
To load a script into the instrument with a specific name, the TSP file must include the shell keywords
loadscript
and endscript, along with the specified script name, as shown in the example file
MyScript1.tsp
, which contains the script:
loadscript Beeper
reset()
beeper.enable = beeper.ON
beeper.beep(2,2400)
endscript
When you load the file
MyScript1.tsp
from the flash drive, a script named
Beeper
is created in
the run-time environment. Note that the script is named using the name that follows the
loadscript
keyword, not the name of the TSP file on the flash drive. After the script is loaded, you
can choose to save it to nonvolatile memory.