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.

Newcomers DBPro Corner / Working with files

Author
Message
SmoothDancer
20
Years of Service
User Offline
Joined: 13th Dec 2003
Location: MeXico
Posted: 2nd Jan 2004 11:15
Hello!

I'm a new programer, I started programming in dbpro 2 weeks ago and I have made a tic-tac-toe game already, now I'm working in an arkanoid style game, I have done the bar/ball/walls colisions and I would like to store the levels data in files like:

1.lv
2.lv

maybe storing the arrays on the files and call them from my main program but, how can i make the .lv files and read them from my program?. Is there a tutorial or something to work with files?

Thank you!

bemanifever.com
ReD_eYe
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 2nd Jan 2004 12:51
the commands you want to look at are:
open to read
open to write
read string
write string
close file

look at the examples that go with them, they might not be that helpful but it should give you an idea.


GO TO THE ETERNAL DESTINY FORUMS!!! http://forums.eternaldestinyonline.com
Do it now!!!
SmoothDancer
20
Years of Service
User Offline
Joined: 13th Dec 2003
Location: MeXico
Posted: 3rd Jan 2004 03:16 Edited at: 3rd Jan 2004 10:20
I can't make it work!

I have tried doing this:



and appears this error:
#100008: Parameter for 'LOAD ARRAY' do not match 'Filename,Array Name(0)' at line 79

I can't open the arrays and also I want to save a variable (in the same "levels1.dat") and load it in my main program too, please help me!

bemanifever.com
SmoothDancer
20
Years of Service
User Offline
Joined: 13th Dec 2003
Location: MeXico
Posted: 3rd Jan 2004 10:28
Please someone!, I'm very confused because it seems that is something simple but I don't understand why I can't make it work.

I'm a newbie who needs your help!

bemanifever.com
Atreides
21
Years of Service
User Offline
Joined: 11th Oct 2003
Location: Switzerland (but NOT on a mountain !)
Posted: 3rd Jan 2004 16:53
it works well for me.. do you have the last patch ?
but you say your problem is at the line 79.. I see only a few lines, are you sure you posted all your code ?

The sleeper must awaken !
SmoothDancer
20
Years of Service
User Offline
Joined: 13th Dec 2003
Location: MeXico
Posted: 3rd Jan 2004 20:38 Edited at: 3rd Jan 2004 20:39
Is working now

If someone have this problem in the future, you need to know this:

-When you are saving/loading you need to specify all the data/arrays (in my case), example:

saving:


Loading:


-The thing that I didn't know is that you need to redim your arrays in your main program:



-That's all!

bemanifever.com
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 4th Jan 2004 02:08 Edited at: 4th Jan 2004 02:13
Your first code snippet where you are using save/load array isn't working because you can only save one array in each file. If you want to save two arrays with the save/load array commands you need two files.

I haven't ever used the load/save array commands in an acutal game, it's better to do what you do in your last post as it's much more flexable.

edit:
Also just incase you don't know if you do
open to write 1,"out.txt"
and out.txt exists nothing will happen when you write data to it. You need to delete the file if it exists before you try and write to it.
if file exist("out.txt") then delete file "out.txt"
open to write 1,"out.txt"

dbpro : 2ghz p4m : 512mb : geforce 4 4200 go

Login to post a reply

Server time is: 2024-11-25 23:17:44
Your offset time is: 2024-11-25 23:17:44