Partial variable access
The expression conforms to the IEC 61131-3 standard.
Partial variable access is possible for IEC variables of data type BYTE, WORD, DWORD or LWORD (data type ANY und ANY_<Typ>).
Syntax:
<Variablenname>.%<Partieller Typ><Partieller Index>
A space is permitted after the dot operator .
. No spaces are allowed after the percent sign % and after the partial type.
| Name of the |
|
Access to Access to |
| From 0 to the index maximum |
For more information, see:
Use
Partial access can only be used for non-temporary variables (user-defined variables, fields, array accesses or dereferencing). This is not permitted for temporary results or literals.
The expression itself is not temporary and can be used as an expression in REFERENCE TO or as an ADR operator.
Sample
bPartialVarB := GVL.nVar.%B0;
bPartialVarX := aArray[nIdx].%X0;
bPartialVarW := nTempVar.%W2;
bPartialVarD := pPointer^.%D2;
bPartialVarB := nVar.%W1.%B1
Partial access is not possible for function calls, index expressions, literals or properties.
Negative sample:
FunctionCall().%B0
(1+index).%B0
(DWORD#16#12345678).%B0
Property.%B0
Index maximum of the partial types
Partial access is only possible if the called expression is of a conforming type and the partial index is less than or equal to the maximum partial index. Otherwise a compiler error is output.
Partial type | Access type | Maximum of the partial index |
---|---|---|
|
| 7 |
| 15 | |
| 31 | |
| 63 | |
|
| 0 |
| 1 | |
| 3 | |
| 7 | |
|
| Not supported |
| 0 | |
| 1 | |
| 3 | |
|
| Not supported |
| Not supported | |
| 0 | |
| 1 | |
|
| Not supported |
| Not supported | |
| Not supported | |
| 0 |
Expression with partial access
The type of a partial access expression depends only on <Partieller Typ>
and must be selected from the following table.
Partial type | Expression type |
---|---|
|
|
|
|
|
|
|
|
|
|
Addresses
It is permitted to form the address of a partial access expression of the partial type B, W, D and L.
It is not permitted to form the address of a partial access expression of partial type X.
It is not permitted to assign a partial access expression of type BIT to a VAR_INOUT variable.
Samples
ADR(nVar.%B0)
refVar REF= nVar.%W1
Negative sample:
ADR(nVar.%X0)
refVar REF= nVar.%X0