2600AS-901-01 Rev. B / September 2008
Return to
19-97
Series 2600A System SourceMeter® Instruments Reference Manual
Section 19: Remote Commands
script
Use the following commands to load a script from the front panel and to save a script to the USB
flash drive.
script.load
Function
Creates a script from a specified file.
TSP-Link
accessibility
This function cannot be accessed from a remote TSP-Link node.
Usage
myscript = script.load(file)
myscript = script.load(file, name)
myscript
The created script, or
nil
if an error is encountered.
file
The path and file name of the script file to load.
name
The name of the script to be created.
Remarks
• If the
name
parameter is an empty string, or name is absent (or
nil
) and the script name cannot
be extracted from the file,
myscript
is the only handle to the created script.
• If the
name
parameter is present and not
nil
, any script name embedded in the file is ignored.
Furthermore, if name conflicts with the name of an existing script in the
script.user.scripts
table, the existing script’s
name
attribute will be set to an empty string
before it is replaced in the
script.user.scripts
table by the newly created script.
• If the
name
parameter is absent or
nil
, the command attempts to extract the name of the script
from the file. Any conflict between the extracted name and that of an existing script in the
script.user.scripts
table generates an error. If the script name cannot be extracted, the
created script's name attribute is initialized to the empty string, and must be set to a valid non-
empty string before saving the script to internal memory.
• The
file
path may be absolute or relative to the current working directory.
• The script’s
name
attribute is initialized to a value which (if not the empty string) also serves as
the key used to access the script through the
script.user.scripts
table. Optional; if
absent or
nil
, an attempt is made to extract the script’s name from the file.
• The file to be loaded must contain the
loadscript
or
loadandrunscript
keywords, the
body of the script, and the
endscript
keyword.
script.new
Function
Creates a script from a chunk of Lua code.
TSP-Link
accessibility
This function cannot be accessed from a remote TSP-Link node.
Usage
myscript = script.new(code)
myscript = script.new(code, name)
myscript
The created script, or
nil
if an error is
encountered.
code
A string representing a chunk of Lua code
to be used as the script body.
name
The name of the script to be created.
Remarks
• If
name
conflicts with the name of an existing script in the
script.user.scripts
table, the
existing script will be unnamed by setting its name attribute equal to the empty string before it is
replaced in the
script.user.scripts
table by the newly created script.
• If the
name
parameter is an empty string, or
name
is absent (or
nil
),
myscript
is the only
handle to the created script.
• The script’s
name
attribute also serves as the key used to access the script through the
script.user.scripts
table. Optional;default is the empty string.