![background image](http://html1.mh-extra.com/html/keithley/3700-series/3700-series_reference-manual_3931523023.webp)
Series 3700 System Switch/Multimeter Reference Manual
Section 2
:
TSP Programming Fundamentals
Document Number: 3700S-901-01 Rev. A / August 2007
2-3
The following chunk is an example that generates an output response message:
x = 10 print(x)
1.000001
NOTE
The output (indicated by the
) may vary dependent on the ASCII precision setting.
Scripts
When taking advantage of the TSP to perform more complicated sequences of commands,
especially sequences utilizing advance scripting features such as looping and branching,
sending the entire sequence in one message is very cumbersome. Use the
loadscript
and
endscript
messages to collect a sequence of commands into one chunk.
The
loadscript
message marks the beginning of a script. The instrument will collect all
following messages until the
endscript
message is received (the
endscript
message
marks the end of the script). The TSP enabled instrument compiles the test sequence and
makes it available to run in a subsequent message. This chunk is called the "active script."
NOTE
Each time the
script.run()
command is given, the active script will be executed.
The active script can be run at any time by sending the command
script.run()
. The active
script can be run many times (it remains in active memory until a new active script is created).
Sending a new script using the
loadscript
and
endscript
messages will instruct the TSP
enabled instrument to replace the active script with the new script.
Creating and using scripts this way is a very powerful feature of TSP enabled instruments, but it
is limited to accessing only one script at a time. The solution to this limitation is to create user-
defined named scripts. See
Named scripts
(on page 2-3) for information on how to use named
scripts, and also how to store many scripts in the instrument at one time.
Named scripts
The
loadscript
message can also be used to create
named scripts
. Loading a
named
script
does not replace the
active script
. Instead, a global variable in the run-time environment
is created to store the script. Because the script is stored in a global variable, the name of the
script must be a legal TSL variable name. Specify the name of the script in the
loadscript
message by separating it from the loadscript keyword with a space character.
For example, the message
loadscript MyScript
will instruct the TSP enabled instrument
to begin gathering command messages that will be used to create a script named
MyScript.
After sending the command messages, the
endscript
message is still used to indicate the
end of the script. Upon receipt of the
endscript
message, the instrument will compile the
script. If there are no errors, the script will be made available as the global variable
MyScript
because that is the name we used in the
loadscript MyScript
message. After a named
script has been successfully sent to the instrument, it can be run at any time by sending the
MyScript()
command.