2-58 TSP Programming Fundamentals
Series 2600 System SourceMeters Reference Manual
2600S-901-01 Rev. A / May 2006
Return to
4
5
Both
and
and
or
use short-cut evaluation, that is, they evaluate their second
operand only when necessary. A useful TSL construct is
x = x or v
, which is
equivalent to:
if not x then x = v end
For example, it sets
x
to a default value
v
when
x
is not set (provided that
x
is not
set to
false
).
To select the maximum of two numbers
x
and
y
, use the following statement (note
the
and
operator has a higher precedence than
or
):
max = (x > y) and x or y
When
x > y
is true, the first expression of the
and
is true, so the
and
results in its
second argument
x
(which is also true, because it is a number), and then the
or
expression, results in the value of its first expression,
x
. When
x > y
is false, the
and
expression is false and so are the
or
results in its second expression,
y
.
The operator
not
always returns
true
or
false
:
print(not nil)
print(not false)
print(not 0)
print(not not nil)
Output of code above:
true
true
false
false
Concatenation
TSL denotes the string concatenation operator by “..” (two dots). If any of its
operands is a number, TSL converts that number to a string:
print(
"
Hello
"
..
"
World
"
)
print(0 .. 1)
Output of code above:
Hello World
01
Содержание SourceMeter 2600 Series
Страница 507: ...AppendixA Specifications Appendix A topics Model 2600S Specifications page A 2 2600S 901 01 Rev A May 2006...
Страница 575: ...AppendixF DisplayCharacterCodes Appendix F topics Introduction page F 2...
Страница 592: ......
Страница 593: ......