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 / Dont understand the system of reading & wrighting to a file

Author
Message
Delta
21
Years of Service
User Offline
Joined: 15th Nov 2002
Location:
Posted: 27th Jan 2003 01:00
How exactly could I read and wright to a file, to save values etc..

I dont really understand the "READ WORD File Number, Variable" because I just cant see how I can specify what i want from the file, same with wrighting,

isnt there any way I could have a file layed out kinda like and INI and read form it? or even just lines of info and get values from specific lines?

botname = Bottyboy
botnumber = 14
botshealth = 43.2

or

Bottyboy
14
43.2

Any help would be great
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 27th Jan 2003 01:19
What you do is read from the file in the same sequence as you write to the file.

Or if you need something more complex, you can store the data in a known format (like an ini file for example) and read down it searching for what you need.
Delta
21
Years of Service
User Offline
Joined: 15th Nov 2002
Location:
Posted: 28th Jan 2003 12:07
"Or if you need something more complex, you can store the data in a known format (like an ini file for example) and read down it searching for what you need."

but how exactly could that be done?
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 28th Jan 2003 13:59
Something like this.



Put the following into a file called c:\myfile.ini


Now play
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 28th Jan 2003 14:02
Oops. Forgot to add a 'close file 1' at the end. Never mind You will need to do this in the code so that you are able to read multiple values.

Alternatively, for speed, read the whole file into an array once, and then scan that for your search strings.

Login to post a reply

Server time is: 2024-05-05 07:48:43
Your offset time is: 2024-05-05 07:48:43