Hi, I have a simple request I told bgt to do. There are 4 menus that will be presented when opening my app, if the user presses m, they can select which one is active when it opens. However, the setting is only saved until the program exists. Can I save this variable without having to serialize a file? The save function only has the line sd.set("launch",launch); and the load function has the if.sd.exists line and the sd.get line. So should I add a line in the save function to change it internally without needing an external file?
#1 (edited by Zarvox 2019-01-04 06:04:18)
All you need do is save this in a global variable. If you want to save this when the program is not loaded, you will need to use a file. There is no other way.
Well, although technically stored in a file, you can also use the registry
golfing in the kitchen
Keep in mind that in a program, a variable only exists until the program closes. To save variables between runtimes you need to either save it to the registry or save it in a file. I highly highly recommend learning serialize and deserialize as they will save you countless hours of frustration when you attempt to write your own settings class. Back before BGT has serialize and deserialize I made my own settings writer and reader. Ugh.