Model 2651A High Power System SourceMeter® Instrument Reference Manual
Section 6: Instrument programming
2651A-901-01 Rev. A / March 2011
6-31
Base library functions
This library provides generic functions for string manipulation.
Base library functions
Function
Description
collectgarbage()
collectgarbage(
limit
)
Sets the garbage-collection threshold to the given limit (in
kilobytes) and checks it against the byte counter. If the new
threshold is smaller than the byte counter, then Lua
immediately runs the garbage collector. If there is no limit
parameter, it defaults to zero (0) (which forces a garbage-
collection cycle). See
for more information.
gcinfo()
Returns the number of kilobytes of dynamic memory that the
Test Script Processor (TSP
®
) scripting engine is using, and
returns the current garbage collector threshold (also in
kilobytes). See
(on page 6-32) for
more information.
print(
e1, e2, ...
)
Receives any number of arguments, and generates a response
message, using the
tostring()
function to convert them to
strings (note that numbers are converted to scientific notation
using
format.asciiprecision
). The output is not
formatted. For formatted output, you can use the
string.format()
command (see
(on
tonumber(
x
)
tonumber(
x, base
)
Returns
x
converted to a number. If
x
is already a number, or a
convertible string, then the number is returned; otherwise, it
returns
nil
.
An optional argument specifies the base to interpret the
numeral. The base may be any integer between 2 and 36,
inclusive. In bases above 10, the letter
A
(in either upper or
lower case) represents 10,
B
represents 11, and so forth, with
Z
representing 35. In base 10, the default, the number may have
a decimal part, as well as an optional exponent. In other bases,
only unsigned integers are accepted.
tostring(
x
)
Receives an argument of any type and converts it to a string in
a reasonable format.
type(
v
)
The possible results of this function are
"nil"
(a string, not
the value nil),
"number"
,
"string"
,
"boolean"
,
"table"
,
"function"
,
"thread"
, and
"userdata"
.