Section 10: Instrument programming Model 2601B-PULSE System SourceMeter Instrument Reference Manual
10-16 2601B-PULSE-901-01A April 2020
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
x = nil
print(x, type(x))
Example: Boolean
y = false
print(y, type(y))
Example: String and number
x = "123"
print(x, type(x))
x = x + 7
print(x, type(x))
123 string
Adding a number to x forces its type to number.
130 number
Example: Function
function add_two(first_value,
second_value)
return first_value + second_value
end
print(add_two(3, 4), type(add_two))
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 runtime environment.