The following functions enable the dynamic allocation of arrays for storing DINT integer values:
ARCREATE allocates an array of DINT integers
ARREAD read a DINT integer in
an arrayallocated by ARCREATE
ARWRITE write a DINT integer in an
arrayallocated by ARCREATE
Important notes
|
ARCREATE: array allocation
OK := ARCREATE (ID, SIZE);
ID : DINT
integer ID to be assigned to the array (first
possible ID is 0)
SIZE : DINT wished number of DINT values
to be stored in the array
OK : DINT return
check
Return values
1
OK - array is allocated and ready for read /
write operations
2 the specified ID is
invalid or already used for another array
3 the specified size is
invalid
4 not enough memory
(action denied by the Operating System)
The memory allocated by ARCREATE will be released when the application stops.
ARREAD: read array element
VAL := ARREAD (ID, POS);
ID : DINT
integer ID of the array
POS : DINT index of the element in
the array (first valid index is 0)
VAL : DINT value of the specified
item or 0 if arguments are invalid
ARWRITE: write array element
OK := ARWRITE (ID, POS, IN);
ID : DINT
integer ID of the array
POS : DINT index of the element in
the array (first valid index is 0)
IN : DINT value to be
assigned to the element
OK : DINT return
check
Return values
1
OK - element was forced successfully
2 the specified ID is
invalid (not an allocated array)
3 the specified index
is invalid (out of array bounds)