Storing data in program slots
Root / Programming Questions / [.]
glennxsergeCreated:
I'm thinking of using one of the program slots as a way to store program data so that it can be easily accessed. However, it appears that all of the editing commands (PRGEDIT/PRGDELETE/PRGINSERT), require user confirmation if there's something already in that slot. Is there a way to bypass that? Like how LOAD has an optional flag for suppressing the need for user input. My program requires frequent and flexible authoring and retrieval of data so I'm hesitant to use the file system.
LOAD "some_file_name", FALSE
The optional FALSE disables the user confirmation.
12Me21, thanks for posting. I just noticed the same thing this morning, but didn't think to update my post. I can't think of a scenario where a user would be in the position of needing to confirm unsaved edits to the slot, unless they had something in prg1 that they had tampered with before running my program. So probably not a big deal, which is great, because this makes data management a breeze for me.
12Me21, thanks for posting. I just noticed the same thing this morning, but didn't think to update my post. I can't think of a scenario where a user would be in the position of needing to confirm unsaved edits to the slot, unless they had something in prg1 that they had tampered with before running my program. So probably not a big deal, which is great, because this makes data management a breeze for me.At the beginning of your game, you could do PRGDEL -1, so the user would know that other slots would be modified. Otherwise, they wouldn't know until they tried to save, and then it would be too late; they would either lose their save data or lose their other program.
12Me21, man you are reading my mind. This is exactly what I ended up doing.
I held off, initially because I thought it might be a nice way to keep data between sessions. If someone were to press start by accident and hadn't saved, at least all the data would still be floating around in the prg1 slot, and since data is written very frequently and almost immediately at the start of the program, it seemed like a decent idea.
Although maybe there is another way that wouldn't require deleting. On program start I could just insert a dummy line at the very end of the prg1 slot, like a comment or something useless, which would trigger the warning, in case a user had edits in prg1 slot. If not, the comment wouldn't intrude on a previous execution of the program, and the data would still exist.
I'll think about this a bit more. Thanks, 12Me21.
12Me21, man you are reading my mind. This is exactly what I ended up doing. I held off, initially because I thought it might be a nice way to keep data between sessions. If someone were to press start by accident and hadn't saved, at least all the data would still be floating around in the prg1 slot, and since data is written very frequently and almost immediately at the start of the program, it seemed like a decent idea. Although maybe there is another way that wouldn't require deleting. On program start I could just insert a dummy line at the very end of the prg1 slot, like a comment or something useless, which would trigger the warning, in case a user had edits in prg1 slot. If not, the comment wouldn't intrude on a previous execution of the program, and the data would still exist. I'll think about this a bit more. Thanks, 12Me21.You could also use a different slot, since 2 and 3 are rarely used.