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 to add the Persistent Variables object to the application object.
CODESYS 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 RETAINandEND_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 RETAINivarpersist2: INT;END_VARClick .
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 createdPOU.IVARPERSIST2 : INT