Description
The instruction "Read from ARRAY data block" is used to read the element from a data block of the ARRAY DB block type to which the index references, and write the value of the element to the target range.
An ARRAY data block is a data block that consists of exactly one ARRAY of <Data type>. The elements of the ARRAY can be of PLC data type or any other elementary data type. Counting of the ARRAY always begins with the low limit "0".
Enable output ENO returns the signal state FALSE if one of the following conditions applies:
-
Enable input EN returns the signal state FALSE.
-
If an error occurs during the execution of the instruction.
Parameters
The following table shows the parameters of the "Read from ARRAY data block" instruction:
|
Parameter |
Declaration |
Data type |
Memory area |
Description |
|---|---|---|---|---|
|
EN |
Input |
BOOL |
I, Q, M, D, L or constant |
Enable input |
|
ENO |
Output |
BOOL |
I, Q, M, D, L |
Enable output |
|
DB |
Input |
DB_ANY |
I, Q, M, D, L |
Data block that is read |
|
INDEX |
Input |
DINT |
I, Q, M, D, L, P or constant |
Element in the DB that is read. The specification can be a constant, a global tag or an indexed value. |
|
VALUE |
Output 1) |
VARIANT |
L (The declaration is possible in the "Input", "InOut" and "Temp" sections of the block interface.) |
Value that is read and output |
|
RET_VAL |
Output |
INT |
I, Q, M, D, L, P |
Error information: If an error occurs during execution of the instruction, an error code is output at the RET_VAL parameter. |
|
1) The VALUE parameter is declared as Output, since the data flow into the tag. However, the tag itself must be declared as InOut in the block interface. |
||||
You can find additional information on valid data types under "See also".
Parameter RET_VAL
The following table shows the meaning of the values of the RET_VAL parameter:
|
Error code* (W#16#...) |
Explanation |
|---|---|
|
0000 |
No error |
|
80B4 |
The element data type stored in the ARRAY data block does not match the element data type transferred in the VARIANT. |
|
80B5 |
The copying was interrupted. |
|
8132 |
The data block does not exist, is too short, write protected, or is located in load memory. |
|
8135 |
The ARRAY data block contains invalid values. |
|
8154 |
The data block has the incorrect data type. |
|
8282 |
The value at the INDEX parameter is outside the limits of the ARRAY. |
|
8450 |
The data type VARIANT at parameter VALUE provides the value "0". |
|
8452 |
Code generation error |
|
8453 |
There are two possible causes of the error:
|
|
* The error codes can be displayed as integer or hexadecimal values in the program editor. You can find information on switching the display formats under "See also". |
|
Example
The following example shows how the instruction works:
The following table shows how the instruction works using specific operand values:
|
Parameters |
Operand |
Value |
|---|---|---|
|
DB |
ArrayDB |
The "ArrayDB" operand is an ARRAY DB of the data type Array [0 to 10] of INT. |
|
INDEX |
2 |
2nd element of the "ArrayDB" |
|
VALUE |
TargetField |
The "TargetField" operand is a global tag of the data type INT. |
If the "TagIn1" operand returns signal state "1", the instruction is executed. The 2nd element is read from "ArrayDB" and written to the "TargetField" operand. If the instruction is executed without errors, the enable output ENO has the signal state TRUE and the "TagOut" output is set.