
2600AS-901-01 Rev. B / September 2008
Return to
12-5
Series 2600A System SourceMeter® Instruments Reference Manual
Section 12: TSP Fundamentals and Script Management
creates it is executed. In this case the chunk that creates it is a script. Therefore, the function will
not exist until the script that creates it is executed. This is often confusing to first time users.
Example: Create the function
MyFunction
with a script named
MakeMyFunction
. The sequence of
messages to do this is shown as follows:
loadscript MakeMyFunction
MyFunction = function (who)
print("Hello " .. who) -- The .. operator concatenates two strings.
end
endscript
After this sequence of messages is sent, the
MakeMyFunction
script exists on the instrument in a
global variable named
MakeMyFunction
. The
MyFunction
function however does not yet exist
because we have not executed the
MakeMyFunction
script. Let us now send the message
MakeMyFunction()
. That message instructs the instrument to run the
MakeMyFunction
script
which then creates the
MyFunction
global variable that happens to be a function.
If we now send the message
MyFunction("world")
, the instrument will execute the
MyFunction
function, which causes the instrument to generate a response message with the text “Hello world”
in it.
Programming overview
What is a chunk?
A chunk is a single programming statement or a sequence of statements that are executed
sequentially. There are non-scripted chunks and scripted chunks.
Single statement chunk:
The following programming statement is a chunk:
print("This is a chunk")
When the above chunk is executed, it returns the following string:
This is a chunk
Multiple statement chunk:
A chunk can also contain multiple statements. Each statement in the
line of code is to be separated by white space. The following chunk contains two statements:
print("This is a chunk") print("that has two statements")
When the above chunk is executed, the two statements are executed sequentially and the
following strings are returned:
This is a chunk
that has two statements
Multiple chunks:
When sent separately, the following two lines of code are two separate chunks.
The first chunk sets the source level of SMU A to 1V and the second chunk turns the output on.
smua.source.levelv = 1
smua.source.output = smua.OUTPUT_ON
Scripted chunk:
In a script environment, the chunk is the entire listing of test programming code.
If the two statements in the above example were created as a script, then those two lines of code
would be considered one chunk. See the topic below,
What is a script?
The Series 2600A utilizes a Test Script Processor (TSP) to process and run individual chunks or
programs called “scripts”. A script is a collection of instrument control commands and