Retain variables maintain their value when the controller is restarted normally (cycling power), or when the command Reset Warm is used. When the program is restarted, the stored values will continue to be used. All other variables are re-initialized either with their defined initialization values or with the standard initializations. However, they will be reset after downloading or using a Reset Cold.
Persistent variables are identified by the keyword PERSISTENT. They must also be set as RETAIN. Like the retain variables they keep their values at a Reset Warm or Reset Cold AND after a download. PERSISTENT RETAINs only get re-initialized at a 'Reset Origin'. An example case for persistent variables is an operation-hour-counter, which should continue counting after a power fail, particularly however also after a new application downloaded.
Note Persistent Variable List is separate from the Global Variable List (GVL). Select the to create the Persistent Variable List. It appears with a different icon as a separate object in the application:
Online > Reset Origin for reset of PERSISTENT RETAIN
VAR_GLOBAL PERSISTENT RETAIN
VAR RETAIN END_VAR VAR PERSISTENT RETAIN
VAR PERSISTENT RETAIN