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.

Author
Message
Jurgen
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location:
Posted: 30th Aug 2003 22:20 Edited at: 30th Aug 2003 22:23
this is my code:
DIM bits(5, 5)

FOR y = 1 TO 5
FOR x = 1 TO 5
READ bits
set cursor x*30,y*30 : print bits
NEXT x
NEXT y

bits:
DATA 01,02,03,04,05
DATA 05,04,03,02,01
DATA 01,02,03,04,05
DATA 05,04,03,02,01
DATA 01,02,03,04,05

wait key


this is coding (don't run to db and type it in just read plz) No seriously, this writes the DATA on the screen, I don't want to just show it, I want to save it in a notebook-file (.dat) and later on load it again...

If I say save array "test.dat",bits(0) and open the dat-file I get all these little squares, so my best guess is that's not THE way... but which one is? And better so, how to load? So my question really is: plz make a sample program (with my code in it) to save this DATA, or, a sample program of how to write numbers in a file and to load those numbers back out, to show them on screen...

Jurgen

"Only when all the seas are poisened, only when all the trees have been cut only when all the animals are killed, people will understand that money can't be eaten..."
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 30th Aug 2003 22:35 Edited at: 30th Aug 2003 22:56
add

bits(y,x)=bits

after the read, the array has to have the data allocated 1st, else when you save it all you save is zeros, you could do it direct with

read bits(y,x)

then

print bits(y,x)

to display them and

save array "data.dat",bits(0)

or

load array "data.dat",bits(0)

should sort it,cheers.

Mentor.
Jurgen
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location:
Posted: 31st Aug 2003 01:51 Edited at: 31st Aug 2003 02:05
I believe you, but don't understand.... maybe you could clear it up with a simple sample? (If it's not much trouble.... ? )

I've never done THIS before, in DiV it worked completely different... even the strings NEEDED to be declared, else nothing worked. When you want to save anything you would have to uuhm.... wait one second, I'll look it up right now:

IF (key(_control) AND key(_s)) savedata[0]=level; savedata[1]=key1; savedata[2]=health; savedata[3]=pos_X; savedata[4]=pos_Y; save("player.dat",offset savedata, sizeof(savedata)); END

A simple loading routine (this one works, designed myself, sry this is the db forum) Now I'll post the loading routine (don't know if it helps of explaning the Darkbasic coding to me)

IF (key(_control) AND key(_l)) load("player.dat",offset savedata); level_end=true; level=savedata[0]; key1=savedata[1]; health=savedata[2]; pos_X=savedata[3]; pos_Y=savedata[4]; break; END

Now this is only normal DiV-coding, where you had defined savedata[5] in your GLOBAL-list. Hope you can guess why I'm having troubles with dbpro, right??

"Only when all the seas are poisened, only when all the trees have been cut only when all the animals are killed, people will understand that money can't be eaten..."
Jurgen
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location:
Posted: 31st Aug 2003 13:58
Sorry, I misread your post... never happened before. Thanks

"Only when all the seas are poisened, only when all the trees have been cut only when all the animals are killed, people will understand that money can't be eaten..."

Login to post a reply

Server time is: 2024-11-25 07:00:18
Your offset time is: 2024-11-25 07:00:18