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.

Newcomers DBPro Corner / Confused by reading files

Author
Message
Black Mesa
18
Years of Service
User Offline
Joined: 25th Mar 2006
Location:
Posted: 23rd Jul 2006 00:18
Im trying to develop a program and I want the user to be able to change one variable by changing a value in a text file rather than changing it in the program. Basically all I want is for the user to be able to input a number from 1 to 99 in a text file so that the number they chose can be used as a variable in my program. Im confused by all the read file types such as "read file" and "read byte" as they all output strange numbers instead of the number in the text file when i try and use them. Any help? Thanks.
Game Man
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location:
Posted: 23rd Jul 2006 02:58 Edited at: 23rd Jul 2006 03:01
You'll need to use the READ STRING command to read the first line of text. Next use the VAL command converting the string to a numerical value.
ThinkDigital
19
Years of Service
User Offline
Joined: 18th Aug 2005
Location: A galaxy far, far away...
Posted: 23rd Jul 2006 03:02
Computers work in that way. When you type "255" in a Notepad file, it isn't storing that as the number 255, it stores it as the number 2, followed by two 5's.

There is a command, "write string" that'll ouput and input readable text. Read byte and such commands are a way to save numbers all together, and not as a series of digits.

So your code would look like this:



That's all there is to it.

Black Mesa
18
Years of Service
User Offline
Joined: 25th Mar 2006
Location:
Posted: 23rd Jul 2006 03:30
Thanks so much.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 23rd Jul 2006 03:34
You could always save an array rather than using the open to write and read commands. I find that command quite effective and even easier than open to read/write.
ThinkDigital
19
Years of Service
User Offline
Joined: 18th Aug 2005
Location: A galaxy far, far away...
Posted: 23rd Jul 2006 04:35
He isn't saving, he's reading from the file. That's the only way I know of to do that.

Login to post a reply

Server time is: 2024-09-25 05:21:44
Your offset time is: 2024-09-25 05:21:44