Declaring VAR PERSISTENT Variables
Below you will declare persistent variables in a persistent variable list and in a POU.
Requirement: A project is opened and contains a program POU. You have selected the option for the textual view in the Declaration Editor category of the options ( menu command).
Click Persistent Variables object to the application object.
to add theCODESYS adds the persistent variable list
PersistentVars below the application object in the device tree, and the editor opens.
In the editor, enter a variable declaration, for example
ivarpersist1 : INT;
betweenVAR_GLOBAL PERSISTENT RETAIN
andEND_VAR
.Double-click the POU in the device tree.
The editor of the POU opens.
Specify the following declaration in the declaration part:
VAR PERSISTENT RETAIN
ivarpersist2
: INT;END_VAR
Click
.The message view opens. If CODESYS has compiled the application without errors, then close the message window and continue with the next step. Otherwise, correct the error(s) and click .
Set the focus in the PersistentVars editor. Click .
CODESYS adds the persistent variable from the persistent variable list PersistentVars to the POU:
// Instance path of the persistent variables created
POU.IVARPERSIST2 : INT