Assignment operator REF=
The operator generates a reference (pointer) to a value.
Syntax:
<variable name> REF= <variable name>
Sample:
PROGRAM MAIN
VAR
refA : REFERENCE TO ST_Sample;
stA : ST_Sample;
refB : REFERENCE TO ST_Sample;
stB1 : ST_Sample;
stB2 : ST_Sample;
END_VAR
refA REF= stA; // represents => refA := ADR(stA);
refB REF= stB1; // represents => refB := ADR(stB1);
refA := refB; // represents => refA^ := refB^; (value assignment of refB as refA and refB are implicitly dereferenced)
refB := stB2; // represents => refB^ := stB2; (value assignment of stB2 as refB is implicitly dereferenced)
END_VAR
See also: