Documentation

Reference data type

A reference is a variable which only contains a link to a variable or to a function block instance. The used variable may be of elementary or derived data type.

  • A reference is declared using the keyword REFERENCE TO. Then, the name of the referrede data type follows.
  • The pointer is initialised using the REF= operator.

Example:

VAR
MyRef: REF_TO INT;
MyVar: INT;
END_VAR

MyVar:= 100;
MyRef:= REF(MyVar); //setting of a reference to a variable
MyRef:= 200; //there is a new value of 200 in the variable now