It is important to remember that each time this function is called, data is read from the EEPROM on the Cronus. The life of an EEPROM is typically rated in the amount of read/write cycles that can be performed and although the EEPROM in the Cronus is rated for 1000's of these, you should still ensure that this function is NOT going to call in every iteration of the main loop. Never use it at the base level of the main and always ensure it is nested within an if statement which will only return TRUE for one iteration, such as event_press.
Persistence in programming means a state which remains after the process that created it has ended. For example, a word processor or paint application achieves this by saving the document to a file. The Cronus does this by writing variable values to its EEPROM (Electrically Erasable Programmable Read-Only Memory). This allows you to save the value of a variable so it can be recalled the next time the script is loaded.
There are a total of 512 persistent variables on the Cronus Zen (512 Private Variable)
Slot Persistent Variables, or SPVAR, are private to a specific memory slot. Each of the memory slots has 64 private variables, which are used to save specific values for one script. For example, Cronus Zen Slot 1 has 64 private variables which no other Slot can access, you cannot read or set the value of Slot 1's variables from Slot 4, and setting the private variables in Slot 1 will not have any effect on the private variables in any other slot. Constants have been created for use with the get and set commands for persistent variables, they are:
Cronus Zen has an additional 48 private variables bringing the total to 64, the additional private variable constants are listed below.
To retrieve the value stored in a persistent variable or to set the value of one, the following functions are available:
Returns the value stored within a persistent variable
Stores a value into a persistent variable
get_pvar returns the value stored in a Persistent Variable while allowing you to specify the minimum and maximum permissible value and a default value should the value stored be outside of that range. The min, max, and default parameters are mainly intended for when you are retrieving values from a Global variable, however, they must still be specified when reading the value of a private variable.
<pvar_constant> : A global or private persistent variable constant <min_value> : The minimum permissible value <max_value> : The maximum permissible value <default_value> : The default value to return should the retrieved value be less then the min_value or greater than the max_value
The stored value or the default value if the stored one is out of range
set_pvar stores the specified value into a persistent variable. As GPC supports treating an int as a boolean value, the get_val command can be used to see if a controller entry simply has a value. For example:
<pvar_constant> : A global or private persistent variable constant. <value> : A value to be stored