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 / My file dosn't read properly. What am I doing wrong?

Author
Message
Sunflash
21
Years of Service
User Offline
Joined: 28th Jun 2005
Location: Seattle, Wa
Posted: 14th Feb 2006 17:06 Edited at: 14th Feb 2006 17:07
I'm sure this is my problem, but I'm not sure what my problem is. Could someone look at this code and tell me why it gives me an error saying the color (it's supposed to be 32) isn't 16, 24, or 32.

My code says this:


And my file (Presets.dat) says:


When FPSC develops enough, lets make a Redwall game!

The Nerd
22
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 14th Feb 2006 17:20
You could eventually do like this:


If I remember correctly you need to read data from a file as strings in darkbasic, then you can convert to values. That code works here

Hope that helps!

-The Nerd

Free Particle Engine for DarkBasic Pro:
http://forum.thegamecreators.com/?m=forum_view&t=60141&b=5
Sunflash
21
Years of Service
User Offline
Joined: 28th Jun 2005
Location: Seattle, Wa
Posted: 14th Feb 2006 17:23
Thanks so much! I really apreciate that. But if it's true that you have to read it as a string and convert it, what is the point of the other READ commands? Like Read File, Read Long, Read Byte etc.

When FPSC develops enough, lets make a Redwall game!

The Nerd
22
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 14th Feb 2006 17:28 Edited at: 14th Feb 2006 17:29
I never thought about that... But if I compile this code:



The text document contains a "1".

Now when it's getting printed in the compiled program it writes "49"...

So the data must get twisted somehow... That's why I read data from a file using strings...

-The Nerd

Free Particle Engine for DarkBasic Pro:
http://forum.thegamecreators.com/?m=forum_view&t=60141&b=5
SimSmall
21
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 14th Feb 2006 17:31
to read the file as it stood in the first post (with no quotes) read long is what you're after
Sunflash
21
Years of Service
User Offline
Joined: 28th Jun 2005
Location: Seattle, Wa
Posted: 14th Feb 2006 17:33
Oh, I'll try that...

When FPSC develops enough, lets make a Redwall game!

The Nerd
22
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 14th Feb 2006 17:34 Edited at: 14th Feb 2006 17:37
@___:

That dosn't work...(Just tried), as it shows in my example the data is somehow getting "twisted" if you don't read it as a string.

I just get an "Runtime Error 1502 - Screen depth is illegal at line 23"

-The Nerd

Free Particle Engine for DarkBasic Pro:
http://forum.thegamecreators.com/?m=forum_view&t=60141&b=5
Sunflash
21
Years of Service
User Offline
Joined: 28th Jun 2005
Location: Seattle, Wa
Posted: 14th Feb 2006 17:39 Edited at: 14th Feb 2006 17:40
hmm, dosn't work.

EDIT: lol, didn't refresh Nerd, so I didn't see your post

When FPSC develops enough, lets make a Redwall game!

Tinkergirl
23
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 14th Feb 2006 17:50
Remember you have 'secret' characters at the end of a line - like the 'line return' character.

Read string seems to ignore these, but read long (etc) may pick them up in ascii form.

If you check out the WIP thread, I've been helping on the Templar Quest thread and in that I have some fairly indepth text file reading. Feel free to take a look.

val() is your friend

(as is len())
Sunflash
21
Years of Service
User Offline
Joined: 28th Jun 2005
Location: Seattle, Wa
Posted: 14th Feb 2006 18:19
Ok, I'll be sure to check into that!
Thanks for your help Nerd, within 5 minutes of asking, I can now return to my project! Thats what I call Support!

When FPSC develops enough, lets make a Redwall game!

The Nerd
22
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 14th Feb 2006 19:21 Edited at: 14th Feb 2006 19:24
No problem mate! Glad I could help!

-The Nerd

Free Particle Engine for DarkBasic Pro:
http://forum.thegamecreators.com/?m=forum_view&t=60141&b=5
SimSmall
21
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 14th Feb 2006 20:54
I always used to use read string instead of long - the one time I try and go fancy, look what happens...
Hobgoblin Lord
20
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 15th Feb 2006 00:40
You could use read byte for this assign 2 bytes for screen width, 2 for screen height and 1 for bit depth. bytes would read as

Width(4,0) 4*256+0
Height(3,0) 3*256+0
Depth(32) 32

The data is not twisted it is stored as bytes thus a number over 255 takes up 2 or more bytes, a number over 65536 takes up 3 or more, etc.. DB will let you store greater values as bytes but as a precaution I always use standard size bytes to avoid a possible problem later.

PS. this method works well if you want to make it so you can import characters from other games (i.e. diabloII) or whatever, into your own game.
BearCDPOLD
22
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 16th Feb 2006 03:29
49 is the ascii value of 1. You cannot enter integers in notepad and read them the same in DB. You have to read up on what Hobgoblin Lord mentioned and learn about memory sizes and uses.


I'm going to eat you!
Sunflash
21
Years of Service
User Offline
Joined: 28th Jun 2005
Location: Seattle, Wa
Posted: 16th Feb 2006 04:42
Ok thanks! I'm starting to see the logic involved

When FPSC develops enough, lets make a Redwall game!

Login to post a reply

Server time is: 2026-07-07 22:39:00
Your offset time is: 2026-07-07 22:39:00