GPC Developer Guides
Constants
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 ✔️ ✔️ set pvar stores a value into a persistent variable ✔️ ✔️ 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 gpc int a, b, c; init { a = get pvar(spvar 1, 0, 10, 5); b = get pvar(spvar 2, 20, 40, 30); c = get pvar(spvar 3, 30,400,100); } main { } 🔴 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 for example gpc int a, b , c; init { a = get pvar(spvar 1, 0, 10, 5); b = get pvar(spvar 2, 20, 40, 30); c = get pvar(spvar 3, 30,400,100); } main { if(event press(xb1 view)){ set pvar(spvar 1, a); set pvar(spvar 2, b); set pvar(spvar 3, c); } } 🔴 syntax set pvar ( \<pvar constant> , \<value>); ⚪ parameters \<pvar constant> a global or private persistent variable constant \<value> a value to be stored 🔵 returns none