Models 707B and 708B Switching Matrix Reference Manual
Section 6: Instrument programming
707B-901-01 Rev. A / August 2010
6-11
Retrieve a script as a single string
To retrieve the entire user script source code as a single string, use the
scriptVar.source
attribute. The
loadscript
or
loadandrunscript
and
endscript
keywords are not included.
To retrieve the source code as a single string, send the command:
print(scriptVar.source)
where
scriptVar
is the name of the script.
Example
Code Notes
print(test1.source)
Retrieve the source of a script named "test7".
If you are using TSB Embedded to retrieve a script:
1. In TSB Embedded, from the User Scripts list, select the script you want to edit. The contents of
the script are displayed.
2. If you want to save the script to a new name, change the name in the TSP Script box and click
Save Script
.
3. Edit the content of the script as needed.
4. Click
Save Script
.
5. For the overwrite message, click
OK
.
Script example: Retrieve the content of scripts
This set of examples:
•
Creates a script that generates an error.
•
Retrieves the source of the script using
scriptVar.source
(on page 7-167).
•
Retrieves the source of the script using
scriptVar.list()
(on page 7-164).
Example: Create a script named scriptVarTest
Code Description
errorqueue.clear()
closedChannels = channel.getclose("1F10")
if closedChannels == nil then
channel.setforbidden("1F10")
else
channel.open("1F10")
channel.setforbidden("1F10")
end
channel.close("1F10")
print(errorqueue.next())
Clears existing errors.
Determine if crosspoint 1F10 is closed.
If 1F10 is currently open, configure it as a forbidden
channel.
If 1F10 is currently closed, open the crosspoint and
set it as a forbidden channel.
Attempt to close 1F10, which should generate an
error.
Check the error queue and print the next error.