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 / Integer misread from .txt file.

Author
Message
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 20th Sep 2010 04:53 Edited at: 20th Sep 2010 04:54
I'm basically reading in a bunch of words from a text file into my program. At the first line in the text file there is a number indicating the number of words in the file. However theat value is is getting misread somehow. So instead of Size being 981, its some number in the millions.


And this is what's in the .txt file


My computer surpasses all the technologies of the day. What computer do I have?

Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 20th Sep 2010 05:10
You're reading an int (READ FILE) as binary and trying to convert the resulting number (something very high) to an int (which it already is) which you assume is the string size?
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 20th Sep 2010 05:21
Well I tried Read Long without the int conversion but that didn't work either.

My computer surpasses all the technologies of the day. What computer do I have?

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 20th Sep 2010 07:06
Read it as a string (just like the words) and convert it to an integer with the VAL() command.



Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 20th Sep 2010 20:02
Thanks, that works.

My computer surpasses all the technologies of the day. What computer do I have?

Login to post a reply

Server time is: 2026-07-22 12:41:42
Your offset time is: 2026-07-22 12:41:42