StickOS
DI-159 PLC Hardware Manual
Variable Declarations
All variables must be dimensioned prior to use. Accessing undimensioned variables results in
an error and a value of 0.
Simple RAM variables
Simple RAM variables can be dimensioned as either integer (32 bits, signed, by default), short
(16 bits, unsigned), or byte (8 bits, unsigned) with the following statements:
dim
var
dim
var
as
(
short
|
byte
)
Multiple variables can be dimensioned in the same statement, by separating them with commas:
dim
var
[
as
...],
var
[
as
...], ...
If no variable size (
short
or
byte
) is specified in a dimension statement, integer is assumed;
if no
as
... is specified, a RAM variable is assumed.
Array RAM variables
Array RAM variables can be dimensioned with the following statements:
dim
var
[
n
]
dim
var
[
n
]
as
(
short
|
byte
)
Note that simple variables are really just array variables with only a single array element in
them, so the array element
var
[
0
]
is the same as
var
, and the dimension
dim
var
[
1
]
is
the same as
dim
var
.
String RAM variables
String RAM variables can be dimensioned with the following statements:
dim
var
$
[n]
Where
n
is the length of the array. Array indices start at 0 and end at the length of the array
minus one.
Note also that string variables are really just a null-terminated view into a byte array variable.
37
Содержание DI-159
Страница 51: ...StickOS DI 159 PLC Hardware Manual 4 is even _ 51...
Страница 76: ...DI 159 Block Diagram 76...
Страница 77: ...Dimensional Drawing 77...