Section 13: Introduction to TSP commands
2470 High Voltage SourceMeter Instrument Reference Manual
13-16
2470-901-01 Rev. A /
May
2019
Example: Function
function add_two(first_value,
second_value)
return first second_value
end
print(add_two(3, 4), type(add_two))
7 function
Example: Table
atable = {1, 2, 3, 4}
print(atable, type(atable))
print(atable[1])
print(atable[4])
Defines a table with four numeric
elements.
Note that the "table" value (shown here
as
a096cd30
) will vary.
table: a096cd30 table
1
4
Delete a global variable
To delete a global variable, assign
nil
to the global variable. This removes the global variable from
the run-time environment.
Operators
You can compare and manipulate Lua variables and constants using operators.
Arithmetic operators
Operator
Description
+
addition
-
subtraction
*
multiplication
/
division
-
negation (for example, c =
−
a)
^
exponentiation
Relational operators
Operator
Description
<
less than
>
greater than
<=
less than or equal
>=
greater than or equal
~=
!=
not equal
==
equal