User manual

Section 2: TSP Programming Fundamentals Series 3700 System Switch/Multimeter Reference Manual
2-6 3700S-901-01 Rev. C / July 2008
Programming overview
Chunk defined
A chunk is a single programming statement or a sequence of statements that
are executed sequentially (that is, sent to Lua as a single line). There are non-
scripted 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 contain multiple statements. Each statement in the line of code
must 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
Each of the following lines of code is a separate chunk. The first chunk sets the
ASCII precision to 10 for readings. The second chunk turns on ASCII readings.
format.asciiprecision = 10
format.data = format.ASCII
Scripted chunk
In a script environment, the chunk is the entire listing of test programming code.
If the two statements in Multiple chunks (on page 2-6) were created as a script,
then those two lines of code would be assembled as one chunk. The instrument
internally constructs a chunk out of a series of messages sent between
loadscript and endscript. Also see Script defined (on page 2-7) for more
details.