Jesscorp wrote:Is it possible to save a variable to pmem without having an interface in the interface config portion?
- Code: Select all
uint16 fileNumber, old_fileNumber;
init {
pmem_load();
pmem_read(4, &fileNumber);
old_fileNumber = fileNumber;
// Make sure the correct filenumber is printed.
printf("<hr>filenumber: <b>%d", fileNumber);
}
main {
//Code to set conditional file number
if(event_active(BUTTON_16)) ++fileNumber;
// This contion will prevent flooding the set_pvar function.
if(old_fileNumber != fileNumber){
// This line is what I use to save conditional file number.
set_pvar(4, fileNumber);
old_fileNumber = fileNumber;
}
}
// The function will run only if the fileNumber value changes.
void set_pvar(uint8 idx, int16 val) {
pmem_write(idx, val);
pmem_save();
printf("filenumber: %d saved.", fileNumber);
return;
}
Here is an example based off your script, it does not require the interactive config.
The filenumber value will increment, every time BUTTON_16 (A / CROSS) is pressed.
The value will save, and carry over the next time you load the script.