Retained values are written to disk whenever they change. They are written using the Pack scheme, allowing complex arrays and linked lists to be persisted. Any modified values that are indirectly pointed to from the retained value will not trigger a rewrite of the retained variable to disk; however, when the instance terminates, either through an instance name change or a stopping instance, the retained values will be written.
This implies that crashes, power failures, etc., can result in the most recent retained values not being on disk if these values contain pointers to values. As a result, retained values are stored in files with one file per instance, and one file per variable. These files are stored in a directory named, "Retained" within the same directory where the ultimate root module's .RUN file or the module containing the retained variable definition is stored. These files are uniquely named; the file name is made up of the names of parent modules concatenated with a dash (-) separator between module names, while the variable name is appended to this string by a plus symbol (+). The final '+' and instance name is not present if the variable is Shared. These files all contain the extension ".VAL".