Dataq DI-159 User Manual page 42

Table of Contents

Advertisement

DI-159 PLC Hardware Manual
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
0xn
'c'
variable
variable[expression]
variable#
( )
! ~
* / %
+ -
>> <<
<= < >= >
== !=
| ^ &
|| ^^ &&
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
decimal constant
hexadecimal constant
character constant
simple variable
array variable element
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
42
StickOS

Advertisement

Table of Contents
loading

Table of Contents