User manual

Series 3700 System Switch/Multimeter Reference Manual Section 2: TSP Programming Fundamentals
3700S-901-01 Rev. C / July 2008 2-21
A script saved in nonvolatile memory named autoexec has special properties
that cause it to run automatically after the Series 3700 is powered on and all
autorun scripts have been executed. For details, see Autoexec script (on page
2-26) and Autorun scripts (on page 2-26).
loadandrunscript
loadsandrunscript name
Where: name is the user-assigned name for the script.
These commands are similar to the loadscript commands, except that the
script will execute (run) after it is loaded into the run-time environment. Also, the
autorun attribute for a named script will be set to "yes" (see Autorun scripts (on
page 2-26)).
Creating a user script (alternative)
An alternate way to create a script is to use script.new, which creates a script
from a chunk of Lua code, using the following command:
myscript = script.new(code, name)
Where:
myscript is the created script or nil, if an error occurred. If the name
parameter is an empty string, this is the only handle to the created script.
code is the string representing a chunk of Lua code, which will be used as
the script body.
name (optional) is the name of the script to be created. The script's name
attribute is initialized to this value, which (if not the empty string) also serves
as the key used to access the script through the script.user.scripts
table. The default is the empty string.
If the name of the script.new script conflicts with the name of an existing
script in the script.user.scripts table, the existing script will be unnamed
(that is, its name attribute will be set to the empty string) before it is replaced in
the script.user.scripts table by the newly-created script.
Example:
To create a new global script called MyTest8 and assign the name attribute to
MyTest8 that displays "Hello from MyTest8" on the display, use the following
command:
MyTest8 = script.new("display.clear()
display.settext('Hello from MyTest8')", 'MyTest8')
To run this script:
MyTest8()