pmem_write — Write persistent memory
void pmem_write(uint8 offset, <anytype> value);
Write on position offset, of the persistent memory RAM array, the value of type and size defined by <anytype>.
<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 |
No value is returned.
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()
.
void set_pvar(uint8 idx, int16 val) { pmem_write(idx, val); pmem_save(); }