Using the RETAIN Keyword in an ST Program
Normally, internal variables are not stored for use after the program or server has been reset. Similarly, they are not transferred to any standby servers.
However, it is possible to store internal values so that:
- They are not reset to their initial values when the server or program is reset
- They are transferred to any standby servers.
To do this, you need to use a RETAIN keyword. The RETAIN keyword instructs the program to store the internal variable so that it can transferred and used after a reset.
In ST programs, you need to use the following format to retain the internal variables:
VAR RETAIN
<Value name> :<Value type>;
END_VAR
Example:
VAR RETAIN
TempConversion: INT;
END_VAR
Where TempConversion is the name of the internal variable and INT is the type of value that it represents (an integer).