Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Saving Varialbe Values

Author
Message
Data
20
Years of Service
User Offline
Joined: 26th Nov 2004
Location: Winnipeg,Canada
Posted: 7th Oct 2005 22:37
I'm not sure if I titled this correctly but My question is:
I made an application in which you may change preferances and options. When I make it a standalone exe will the preferances such as new passwords, colour, fonts etc. be saved if I changed them and restarted the program or is there something I would have to do so it is saved?

Knowledge is the key of power. In other words if you hate programming you are weak.
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 7th Oct 2005 22:43
Yes, they will have to be saved:
thing1$="On "
thing2$="High "
dim Savething$(2)
Savething$(1)=thing1$
Savething$(2)=thing2$
save array "things.txt",Savething$()

That will save the array of settings...
Data
20
Years of Service
User Offline
Joined: 26th Nov 2004
Location: Winnipeg,Canada
Posted: 7th Oct 2005 22:56
thing1$="On "
thing2$="High "
dim Savething$(2)
Savething$(1)=thing1$
Savething$(2)=thing2$
save array "things.txt",Savething$()



so that's the way I should do it?

Knowledge is the key of power. In other words if you hate programming you are weak.
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 7th Oct 2005 22:58 Edited at: 7th Oct 2005 22:59
You have to change save array "things.txt",Savething$(), to:
save array "things.txt",Savething$(1)

But you can change it from thing1$ and stuff. You can even save numbers like this:

thing1#=2
thing2#=3
dim Savething$(2)
Savething$(1)=thing1#
Savething$(2)=thing2#
save array "things.txt",Savething$(1)


But loading is a whole different story. Ask me if you need help with loading the data.

PS: It will make a file called "things.txt" in the foldor of you project that this is in.
Data
20
Years of Service
User Offline
Joined: 26th Nov 2004
Location: Winnipeg,Canada
Posted: 7th Oct 2005 23:08
okay thanks but I guess I need to load too. In order to apply the
preferances.

Knowledge is the key of power. In other words if you hate programming you are weak.
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 7th Oct 2005 23:32 Edited at: 7th Oct 2005 23:37
if file exist("things.txt")
open to read 1,"things.txt"
read string 1,thing1$
read string 1,thing2$
Print thing1$; " " ; thing2$
wait key
else
thing1$="2"
thing2$="3"
dim Savething$(2)
Savething$(1)=thing1$
Savething$(2)=thing2$
save array "things.txt",Savething$(1)
endif



There you go ! tell me if there are any problems!

PS: You will have to compile the program twice for the numbers to show up!
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 7th Oct 2005 23:35 Edited at: 7th Oct 2005 23:36
Deleted by me
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 8th Oct 2005 00:34
I have a tutorial on File I/O (Loading/Saving) on www.matedit.com which you might like to check out.

I need someone who is unfamiliar with the subject to give me some feedback on it.

TDK_Man

Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 8th Oct 2005 04:38
Hey TDK,

Was my work good? I seem to be catching up to you
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 8th Oct 2005 06:47
Quote: "I seem to be catching up to you"


That's only because I stopped a long time ago!

TDK_Man

Login to post a reply

Server time is: 2025-05-22 13:38:57
Your offset time is: 2025-05-22 13:38:57