Section 6: Instrument programming  Model 2657A High Power System SourceMeter® Instrument Reference Manual
 
6-46  2657A-901-01 Rev. B/December 2012 
 
Example: Retrieve the content of a script with scriptVar.list() 
 
test.list() 
 
Request a listing of the source of test. 
An example of the possible instrument output is 
shown here (note that the loadscript and 
endscript commands are included). 
 
Output: 
loadscript scriptVarTest 
listTones = {100, 400, 800} 
for index in listTones do 
   beeper.beep(.5, listTones[index]) 
end 
endscript 
Example: Retrieve the content of a script with scriptVar.source 
 
print(test.source) 
 
Request a listing of the source of the script named 
test. The loadscript and endscript 
commands are not included. 
An example of the possible instrument output is: 
listTones = {100, 400, 800} 
for index in listTones do 
   beeper.beep(.5, listTones[index]) 
end 
 
Delete user scripts from the instrument 
In most circumstances, you can delete a script using script.delete() (as described in Delete 
user scripts (on page 6-9)), and then turn the instrument off and back on again. However, if you 
cannot turn the instrument off, you can use the following steps to completely remove a script from the 
instrument. 
When you completely remove a script, you delete all references to the script from the run-time 
environment, the script.user.scripts table, and nonvolatile memory. 
 
To completely remove a script: 
1.  Remove the script from the run-time environment. Set any variables that refer to the script to 
nil or assign the variables a different value. For example, to remove the script "beepTwoSec" 
from the run-time environment, send the following code: 
beepTwoSec = nil 
2.  Remove the script from the script.user.scripts table. Set the name attribute to an empty 
string (""). This makes the script nameless, but does not make the script become the anonymous 
script. For example, to remove the script named "beepTwoSec", send the following code:  
script.user.scripts.beepTwoSec.name = "" 
3.  Remove the script from nonvolatile memory. To delete the script from nonvolatile memory, 
send the command: 
script.delete("name") 
Where name is the name that the script was saved as. For example, to delete "beepTwoSec", 
you would send: 
script.delete("beepTwoSec")