2019-01-04 06:03:00 (edited by Zarvox 2019-01-04 06:04:18)

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?

Thumbs up

2019-01-04 07:45:35

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.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.

Thumbs up +1

2019-01-04 15:21:37

Well, although technically stored in a file, you can also use the registry

golfing in the kitchen

Thumbs up +1

2019-01-05 12:59:06

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.

My name is Inigo Montoya. You killed my space bar. Prepare to die!