Persistent Variables
Persistent variables are locations in the Titan One EEPROM memory to save and retrieve values. The device will retain the contents of persistent variables even if it is without power. A GPC script can access up to 32 persistent variables, where 16 are private for the slot and 16 are common between all slots. Common persistent variables are mainly intended to exchange of information between scripts, while private persistent variables are used to save and load run-time configurations.
Related GPC Functions:
Private Persistent Variable - Identifiers:
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
|
Common Persistent Variable - Identifiers:
PVAR_1, PVAR_2, PVAR_3, PVAR_4,
PVAR_5, PVAR_6, PVAR_7, PVAR_8,
PVAR_9, PVAR_10, PVAR_11, PVAR_12,
PVAR_13, PVAR_14, PVAR_15, PVAR_16
|
1. get_pvar
Returns the value of a Persistent Variable.
Prototype:
int get_pvar ( <identifier>, <min>, <max>, <default> )
Parameters:
<identifier> : the identifier of a Persistent Variable
<min> : the minimum expected value
<max> : the maximum expected value
<default> : the default value to be returned in case of the stored value is out of range specified by min and max
Return:
Return the stored value or the default value
Example:
int pv;
init {
pv = get_pvar(SPVAR_12, -10, 148, 20);
}
|
2. set_pvar
Assigns a value to a Persistent Variable.
Prototype:
set_pvar ( <identifier>, <value> )
Parameters:
<identifier> : the identifier of a Persistent Variable
<value> : the int value to be saved
Return:
None
Example:
set_pvar(PVAR_3, 80);
|