DI-159 PLC Hardware Manual
StickOS
Expressions
StickOS BASIC expressions are very similar to C expressions, and follow similar precedence
and evaluation order rules.
The following operators are supported, in order of decreasing precedence:
n
decimal constant
0xn
hexadecimal constant
'c’
character constant
variable
simple variable
variable[expression]
array variable element
variable#
length of array or string
(
)
grouping
! ~
logical not, bitwise not
* / %
multiply, divide, mod
+ -
add, subtract
>> <<
shift right, left
<= < >= >
inequalities
== !=
equal, not equal
| ^ &
bitwise or, xor, and
|| ^^ &&
logical or, xor, and
The plus and minus operators can be either binary (taking two arguments, one on the left and
one on the right) or unary (taking one argument on the right); the logical and bitwise not oper-
ators are unary. All binary operators evaluate from left to right; all unary operators evaluate
from right to left.
Note that the # operator evaluates to the length of the array or string variable whose name pre-
cedes it.
Logical and equality/inequality operators, above, evaluate to 1 if true, and 0 if false. For con-
ditional expressions, any non-0 value is considered to be true, and 0 is considered to be false.
If the expression references an input "pin variable", the corresponding DI-159 PLC input pin is
sampled to evaluate the expression.
Note that when StickOS parses an expression and later displays it (such as when you enter a
program line and then list it), what you are seeing is a de-compiled representation of the com-
piled code, since only the compiled code is stored, to conserve RAM and flash memory. So
42
Содержание DI-159
Страница 51: ...StickOS DI 159 PLC Hardware Manual 4 is even _ 51...
Страница 76: ...DI 159 Block Diagram 76...
Страница 77: ...Dimensional Drawing 77...