pmem_read — Read persistent memory
void pmem_read(uint8 offset, <anytype> *variable);
Update the variable pointed by *variable with the value of type and size defined by <anytype>, located in the position offset from the persistent memory RAM array.
uint8 pmem_read(uint8 offset);
Read the uint8 value from position offset of the persistent memory RAM array.
<anytype> can be: int8 , uint8 , int16 , uint16 , int32 , uint32 , fix32 or any of its aliases. |
Byte Size of Variable Types | ||
---|---|---|
int8 , uint8 | 1 byte | |
int16 , uint16 | 2 bytes | big-endian |
int32 , uint32 , fix32 | 4 bytes | big-endian |
The persistent memory is an array of 128 bytes that can be used to store data structures such that they can continue to be accessed even after the end of the GPC script that created or last modified them.
For performance reasons the operations pmem_read()
and pmem_write()
are performed in RAM, therefore the persistent memory contents should first be loaded into RAM space by pmem_load()
and, if modified, saved with pmem_save()
.
bool checkbox_value; uint8 radiobox_value; uint8 combobox_value; int spinbox_value; fix32 spinboxf_value; int slider_value; int dial_value; init { pmem_load(); // Load permanent memory before use any pmem operation // Store the values from the permanent memory into variables. checkbox_value = (pmem_read(0) >> 7) & 0b1; radiobox_value = pmem_read(1); combobox_value = pmem_read(2); pmem_read(3, &spinbox_value); pmem_read(5, &spinboxf_value); pmem_read(9, &slider_value); pmem_read(11, &dial_value); }