The expression complies with the IEC 61131-3 standard.
Partial variable access is possible in the case of IEC variables of data type BYTE, WORD, DWORD or LWORD (data type ANY, ANY_<type> ).
Syntax:
<variable name>. % <partial type> <partial index>
A space is allowed after the dot operator (.). No spaces are allowed after the percent sign (%) and after the partial type.
|
<variable name> |
Name of the |
|
<partial type> |
Access to Access to |
|
<partial index> |
From 0 to the index maximum |
For more information, see:
Partial access can be used only for non-temporary variables (user-defined variables, fields, array accesses, or dereferencing). This is not allowed 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.
Example 200. Example
// Implementation PartialVarB := GVL.Variable.%B0; PartialVarX := array[idx].%X0; PartialVarW := tempVariable.%W2; PartialVarD := ptr^.%D2; PartialVarB := variable.%W1.%B1
Partial access is not possible in the case of function calls, index expressions, literals, or properties.
Negative example:
FunctionCall().%B0 (1+index).%B0 (DWORD#16#12345678).%B0 Property.%B0
Partial access is possible only if the called expression has a conforming type and the partial index is less than or equal to the maximum partial index. Otherwise a compiler error is reported.
The type of a partial access expression depends only on <partial type> and has to be selected using the following table.
|
Partial Type |
Type of Expression |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
It is allowed to create the address from a partial access expression of partial type B, W, D, and L.
It is not allowed to create the address from a partial access expression of partial type X.
It is not allowed to assign a partial access expression of type BIT to a VAR_INOUT variable.
Example 201. Examples
ADR(var%.B0) referenceVariable REF= var.%W1
Negative example:
ADR(var.%X0) ref REF= var.%X0