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 Professional Discussion / How to read a text file

Author
Message
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 30th Jan 2014 21:23
Hello.

How can I read a text file and pull certain strands out of it as data? The fields are per-determend

Thanks.
ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 30th Jan 2014 22:02


Alternatively there are read byte, read word, read float and read long (which is used for integers as well as dwords).

Furthermore you can use this:


I never used this method tbh, but I guess this is how it's used. You can then continue reading the data manually out of the memblock. This might or might not be faster than the other method but is often less comfortable. Not sure how make memblock from file differs from load memblock fileID, memID though...

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 31st Jan 2014 09:06
I used the make memblock from file for my zip file reader.
http://forum.thegamecreators.com/?m=forum_view&t=203250&b=6

It's a lot more convenient for certain types of files because you can treat it like a random access file, whereas open to read only gives you sequential access. If your file is all text, then sequential access is probably all you need.


Quote: "Not sure how make memblock from file differs from load memblock fileID, memID though..."

What's load memblock? I don't seem to have that command in my DBP.

ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 31st Jan 2014 11:52
Quote: "What's load memblock? I don't seem to have that command in my DBP."


Oh right, my bad. I actually meant read memblock, and as it turns out the difference is that write/read memblock allows you to write/read a memblock to/from a file just like a byte or integer, so it's not a 1:1 file to memblock relation as with make memblock from file.

Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 31st Jan 2014 14:46
Thanks guys!

Quote: " If your file is all text, then sequential access is probably all you need."


Yah I just wanted to be able to set the properties for an object outside of DBP.

Again thanks!

Login to post a reply

Server time is: 2026-07-07 03:46:46
Your offset time is: 2026-07-07 03:46:46