High Voltage SourceMeter Instrument Reference Manual Section 13:
Introduction to TSP commands
2470-901-01 Rev. A / May 2019 13-15
To determine the type of a variable, you can call the type() function, as shown in the examples
below.
The output you get from these examples may vary depending on the data format that is set.
Example: Nil
print(x, type(x))
Example: Boolean
print(y, type(y))
Example: Hex constant
You can enter hexadecimal values, but to return a hexadecimal value, you must create a function, as
shown in this example. Note that hexadecimal values are handled as a number type.
hex = function (i) return "0x"..string.format("%X", i) end
print(hex(0x54|0x55))
Set the format to return hexadecimal values, then OR two hexadecimal values and AND two
hexadecimal values.
Output:
0x55
Example: Binary constant
Binary values are returned as floating point decimal values. Note that binary values are handled as a
number type.
y = 0B1111111100000000
print(x, type(x))
65280 number
Example: String and number
print(x, type(x))
x = x + 7
print(x, type(x))
Adding a number to x forces its type to
number.
130 number