2600S-901-01 Rev. C / January 2008 Return to Section Topics 2-45
Series 2600 System SourceMeter® Instruments Reference Manual Section 2: TSP Programming
Test Script Language (TSL) reference
Introduction
A script is a program that the Test Script Processor (TSP) executes. A script is written using the
Test Script Language (TSL). TSL is an efficient language, with simple syntax and extensible
semantics. TSL is derived from the Lua programming language, Copyright
© 1994-2004 Tecgraf,
PUC-Rio. See http://www.lua.org, the official website for the Lua Programming Language, for more
information. Also, http://lua-users.org internet site is created for and by users of Lua programming
language and is another source of useful information.
Reserved words
and function return
elseif nil until
for repeat else
local true false
then do in
break if or
end not while
Variables and types
TSL has six basic types; nil, Boolean, number, string, function, and table. TSL is a dynamically
typed language, which means variables do not need to be declared as a specific type. Instead,
variables assume a type when a value is assigned to them. Therefore, each
value carries its own
type. If a variable has not been assigned a value, the variable defaults to the type nil. All numbers
are real numbers. There is no distinction between integers and floating-point numbers in TSL.
var = nil -- var is nil.
var = 1.0 -- var is now a number.
var = 0.3E-12 -- var is still a number.
var = 7 -- var is still a number.
var = "Hello world!" -- var is now a string.
var = "I said, Hello world!" -- var is still a string.
var = function(a, b) return(a+b) end -- var is now a function
that adds two numbers.
var = {1, 2., 3.00e0} -- var is now a table (i.e.,
array) with three
initialized members.
Nil is a type with a single value, nil, whose main property is to be different from any other value.
Global variables have a
nil value by default—before a first assignment—and you can assign nil
to a global variable to delete it. TSL uses
nil as a kind of non-value to represent the absence of
a useful value.