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 / a tutorial for saving/reading data from a file

Author
Message
FROGGIE!
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: in front of my computer
Posted: 14th Nov 2004 23:34
ne1 know ne

I should have changed my signature when asked
Ali M Oldboy
20
Years of Service
User Offline
Joined: 6th Nov 2004
Location: England, UK
Posted: 15th Nov 2004 02:37
Urr...Well I've helped you a couple of times!

-ALI-

N U K E S O F T :: DANGER! EXPLOSIVE GAMES :: [href]http://www.geocities.com/nukesoft0[img]
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 15th Nov 2004 05:15
You can have up to 32 files open at once.

To begin using a file you must open it with either:
OPEN FILE TO READ filenum, filename$
or
OPEN FILE TO WRITE filenum, filename$

Choose the language depending upon the task you wish to perform.
When you are done using the file it is a good idea to use CLOSE FILE filenum to close the file just to make sure.

Once you have a file open you can read from it, or write to it depending on the command you used to open it.

There are six types of values you can read from/write to files.
FILE
BYTE
WORD
LONG
FLOAT
STRING

I haven't worked out the intricacies of each file type yet, I'll need to dig up that old DarkBasic book to get the specifics. Basically you determine what type of value you need to write/read depending upon the limitations of each data type. Then you can use a command such as:

READ STRING filenum, var$

Where filenum is an open file and var$ is the string variable you wish to store the value in. You can also use arrays with read/write statements instead of just plain variables. Also, STRING can be any of the above mentioned data types.

Two other important commands are FILE OPEN() and FILE END(). These will return a 1 if a file is open (in the case of FILE OPEN() ) or if you have reached the end of a file (in the case of FILE END() ). Once you have reached the end of a file anymore data you read from it is worth moot. I don't know if DBC can pick out individual lines from a file, I've just been making due with closing and opening the file again and keeping track of where different things are located.

There are also many file management a directory commands. Those should be easy enough to figure out if you read the help file. It's just basic DOS stuff.

Crazy Donut Productions, Current Project: Project Starbuks
Sony stole our name!
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th Nov 2004 04:57
http://www.thegamecreators.com/?m=codebase_view_code&i=b6c4a300eac7a575df83839971337184
download the extra file, it contains the tutorial document. Explains what arrays are and how to write files.

"eureka" - Archimedes
FROGGIE!
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: in front of my computer
Posted: 18th Nov 2004 02:37
thanks for the help

I should have changed my signature when asked

Login to post a reply

Server time is: 2025-05-24 12:15:25
Your offset time is: 2025-05-24 12:15:25