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 / Saveing varibles/arrays

Author
Message
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 15th May 2009 18:02
I was going to save the following arrays and load them when I

needed.



But, I Just Realized that will create 31 files on your computer.

Can I ,still useing arrays, save all of these arrays to one file?

I've all ready done alot of code with these arrays so it might be

hard to change all of them to write to file.(unless I use the relace

thingy on all of these arrays.)

If at first you don't succeed-Pause-Go to last checkpoint
spt games
16
Years of Service
User Offline
Joined: 14th Apr 2009
Location: United Kingdom
Posted: 15th May 2009 18:11
To quote TDK:

Quote: "There is a command in DB for saving arrays, but you cannot save more than one array in the same file as the command has to be supplied with the filename."


So if you use the SAVE ARRAY command then you can only save ONE array per file. However, you can save the data as strings then read it back in again and convert it back to numbers.

See TDKs File Access tutorial if you need help:
http://forum.thegamecreators.com/?m=forum_view&t=96084&b=7
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 15th May 2009 19:08
You could create 1 BIG array and save/load that one, but it would require a LOT more code.

Probably the best way would be to make all 31 and then load them into a pak file (kinda like a zip file, but not compressed). DBC has commands that support it, but that way 31 files can all be thrown into 1 file for easy storage and then you open the pak file and load the arrays.

And I notice most of all of those are only a size 1. Perhaps some could be combined? For instance, you could just have a single experience variable that has ALL experience ever gotten and re-calculate the level.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 15th May 2009 19:52
whats wronge with my code it won't write to the file


If at first you don't succeed-Pause-Go to last checkpoint
spt games
16
Years of Service
User Offline
Joined: 14th Apr 2009
Location: United Kingdom
Posted: 15th May 2009 20:56
Whats the value of arrays$? Is it either a filename or a path to a file?
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 15th May 2009 21:18
has arrays$ been defined? if not you are trying to create a file with the name of "", that is, nothing, and it can't work.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 15th May 2009 21:35 Edited at: 15th May 2009 21:37
im trying to make a program where when you first try the program
day(1)=3 and it =5 at the end of the program and when you exit and play again day=5

so in short it reads file,makes file,writes array into file

arrays$ is the file name

If at first you don't succeed-Pause-Go to last checkpoint
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 15th May 2009 23:11
Is that all the code though? If it is you will need an array$="Filename" line at the beginning.

Post all of you code, since there isn't a whole lot to go off of there.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 16th May 2009 04:17 Edited at: 16th May 2009 04:35
all right all im trying to figure out is how to save an array to a

file and then reading it later.I already read tdk's example but

when i put in my own stuff it does'nt work.So could someone please

give me a example.

If at first you don't succeed-Pause-Go to last checkpoint
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 16th May 2009 05:24 Edited at: 16th May 2009 05:29
all right i did what you said bn2 and it works

but, it does'nt remember what it =s when i run it again

this is all the code but i'm useing it for my text game



If at first you don't succeed-Pause-Go to last checkpoint
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 17th May 2009 21:10 Edited at: 17th May 2009 21:11
thanks for the help.this is my final outcome(BN2,i know you said i

could combine some of them but i did that on my last project and i

had a mess.I had to keep on going back because i put the wrong

array number down.and because i've already started to use the

arrays.)


If at first you don't succeed-Pause-Go to last checkpoint
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 18th May 2009 04:43
a good idea in my oppinion. when you dealing with arrays is keep a text file that shows what all the array positions are. my programs would be a huge mess without text files lol

New Site! Check it out \/

Login to post a reply

Server time is: 2025-05-14 21:12:20
Your offset time is: 2025-05-14 21:12:20