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 / How to read/write variables to a file in DB Pro

Author
Message
sgalland
22
Years of Service
User Offline
Joined: 18th Nov 2002
Location: United States
Posted: 12th May 2006 03:04
I have a question concerning reading/writing variables to a file. I am trying to write a program to generate data and it has to have theh ability to dump those variables into a file and then open it again. I can read/write files, I just have no idea on how to take complex data such as integers, strings, and arrays and dump them in a file that can be read without screwing up my data. Any help/tutorials is appreciated.
The end is near
19
Years of Service
User Offline
Joined: 19th Jun 2005
Location: USA
Posted: 12th May 2006 05:50 Edited at: 12th May 2006 05:52
to write:


to read:


stargate sg-1 the one show that never gets old
sgalland
22
Years of Service
User Offline
Joined: 18th Nov 2002
Location: United States
Posted: 12th May 2006 07:27
Thanks, the code seems logical and compiles and runs, but it never writes anything to the file, and I just changed the file to test.txt. So I am kinda wondering why nothing is being put into the file? Programmer error?
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 12th May 2006 11:21 Edited at: 12th May 2006 13:41
Quote: "Thanks, the code seems logical and compiles and runs, but it never writes anything to the file, and I just changed the file to test.txt. So I am kinda wondering why nothing is being put into the file? Programmer error?"


Indeed it is... He forgets to close the file Remember to always close the file after having used open to read/write. And I don't know what db you use... But in DBPRO there is no command named "read integer" or "write integer". Should be something like "read long" and "write long".

It should look like this:

Write:


Read:


Those two sources works here. If you can't compile it then I guess it's because you own dbc... Then just change "read long" and "write long" to "read integer" and "write integer".

[edit]

Okay the command "write integer" doesn't work in DBC either...

Also, you could try using the command "write byte" instead...

[/edit]

-The Nerd

3D Arcade-like game:
SpaceBattle-Shootout
The end is near
19
Years of Service
User Offline
Joined: 19th Jun 2005
Location: USA
Posted: 12th May 2006 15:38
oh. Srry!

stargate sg-1 the one show that never gets old
sgalland
22
Years of Service
User Offline
Joined: 18th Nov 2002
Location: United States
Posted: 12th May 2006 16:26
Yeah I caught the integer and changed it to long, but thanks for correcting the code! My problem with Dark Basic Pro is that everything is too easy and I expect my problems to be harder and I miss the simple stuff I had an idea of what I was doing, just wasn't exactly sure that I was doing it right...

Thanks again,
Sean

Login to post a reply

Server time is: 2024-11-27 19:46:52
Your offset time is: 2024-11-27 19:46:52