Persistent Memory
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:
SPVAR_1
SPVAR_2
SPVAR_3
SPVAR_4
SPVAR_5
SPVAR_6
SPVAR_7
SPVAR_8
SPVAR_9
SPVAR_10
SPVAR_11
SPVAR_12
SPVAR_13
SPVAR_14
SPVAR_15
SPVAR_16
Cronus Zen has an additional 48 private variables bringing the total to 64, the additional private variable constants are listed below:
SPVAR_17
SPVAR_18
SPVAR_19
SPVAR_20
SPVAR_21
SPVAR_22
SPVAR_23
SPVAR_24
SPVAR_25
SPVAR_26
SPVAR_27
SPVAR_28
SPVAR_29
SPVAR_30
SPVAR_31
SPVAR_32
SPVAR_33
SPVAR_34
SPVAR_35
SPVAR_36
SPVAR_37
SPVAR_38
SPVAR_39
SPVAR_40
SPVAR_41
SPVAR_42
SPVAR_43
SPVAR_44
SPVAR_45
SPVAR_46
SPVAR_47
SPVAR_48
SPVAR_49
SPVAR_50
SPVAR_51
SPVAR_52
SPVAR_53
SPVAR_54
SPVAR_55
SPVAR_56
SPVAR_57
SPVAR_58
SPVAR_59
SPVAR_60
SPVAR_61
SPVAR_62
SPVAR_63
SPVAR_64
To retrieve the value stored in a persistent variable or to set the value of one, the following functions are available:
Function
Description
Zen
Plus
get_pvar
Returns the value stored within a persistent variable
Yes
Yes
set_pvar
Stores a value into a persistent variable
Yes
Yes
get_pvar
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.
Code-Snippet
Syntax
get_pvar ( <pvar_constant>, <min_value>, <max_value>, <default_value> )
Parameters
<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
Returns
The stored value or the default value if the stored one is out of range
set_pvar
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.
Code-Snippet
Syntax
set_pvar ( <pvar_constant> , <value> );
Parameters
<pvar_constant> : A global or private persistent variable constant.
<value> : A value to be stored
Returns
None
Last updated

