
Section 6: Instrument programming
2606B System SourceMeter® Instrument Reference Manual
6-42
2606B-901-01 Rev. B / May 2018
For example, to change the name of the script named
test2
to be
autoexec
:
test2.name = "autoexec"
test2.save()
The
autoexec
script runs automatically when the instrument is turned on. It runs after all the scripts
have loaded and any scripts marked as autorun have run.
You can also use the
script.new()
and the
scriptVar.
source
attribute commands to create a
script with a new name. For example, if you had an existing script named
test1
, you could create a
new script named
test2
by sending the command:
test2 = script.new(test1.source, "test2")
See
(on page 7-163).
Retrieve a user script
There are several ways to retrieve the source code of a user script:
•
One line at a time: Use
scriptVar
.list()
to retrieve the source code one line at a time
•
Entire script: Use the
print(
scriptVar
.source)
command to retrieve the script source code
as a single string
•
Use TSB Embedded
See
(on page 6-3) for information about recreating the script and loading it
back into the instrument.
To get a list of scripts that are in nonvolatile memory, use the
(on page 7-165)
function.
Retrieve source code one line at a time
To retrieve the source code one line at a time, send the
scriptVar
.list()
command. When this
command is received, the instrument sends the entire script. Each line of the script is sent as a
separate response message. The output includes the
loadscript
or
loadandrunscript
and
endscript
keywords.
After retrieving the source code, you can modify and save the command lines as a user script under
the same name or a new name.
To retrieve the source code of a script one line at a time, send the command:
scriptVar
.list()
Where
scriptVar
is the name of the script.
To retrieve the commands in the anonymous script, use
script.anonymous.list()
.