Page 1 of 1
Save variable to the program
Posted: Sun Jan 10, 2010 12:24 am
by donSHAYA
Hi all
If I have a variable that I want to save in the program, how do I do that? I tried:
Code: Select all
Global Start.i, Var.i
Restore Save
Read.i Start
Start + 1
Var = Start
DataSection
Save:
Data.i Var
EndDataSection
Thank you
Re: Save variable to the program
Posted: Sun Jan 10, 2010 12:48 am
by ts-soft
Code: Select all
Global Start.i, Var.i
PokeI(?Save, 4711)
Restore Save
Read.i Start
Debug Start
DataSection
Save:
Data.i 0
EndDataSection
only joking
Re: Save variable to the program
Posted: Sun Jan 10, 2010 1:55 am
by Kaeru Gaman
a preference file or a registry value would be the correct approach.
Re: Save variable to the program
Posted: Sun Jan 10, 2010 5:25 am
by donSHAYA
I tried the PokeI() but when I close the program and open it again, it doesnt remember the value of the variable var when I closed the program last time.
I wanna do it without any files.
Thank you for the replies though.
Re: Save variable to the program
Posted: Sun Jan 10, 2010 6:02 am
by Demivec
donSHAYA wrote:I tried the PokeI() but when I close the program and open it again, it doesnt remember the value of the variable var when I closed the program last time.
I wanna do it without any files.
You would have to modify the original file on disk to change the values it starts with in its DataSection. Either way you are going to have to modify something on the disk. Better to leave the original alone and create a new file just for data.
Re: Save variable to the program
Posted: Sun Jan 10, 2010 11:31 am
by blueznl
You have to create a file, and store data in there, see the help file for OpenPreferences() or check here:
http://www.xs4all.nl/~bluez/purebasic/p ... ile_system
Re: Save variable to the program
Posted: Sun Jan 10, 2010 8:41 pm
by donSHAYA
Oh ok. Thank you