trouble with ascii and EOF

cguygo
10-27-2004, 12:06 PM
Hey guys,

I have a situation with an Ascii character. I open a file and read in the strings one line at a time. Things are fine until it comes across the ascii character 26. When it hits this character my program thinks it is the end of the string and will not print the rest of the string...for that matter it kicks me out of the loop thinking that we are at EOF.
I tried replacing it after i read in the string but as soon as it hits chr$(26) during the input it just stops there...so when i try to replace it it isnt there.

anyone ran into this?...I can give some more details if anyone has an idea of how to fix this.

guy

webbone
10-27-2004, 12:09 PM
Ctrl-Z (chr$(26)) is used as 'EOF' on the DOS command line so I suspect that a related behaviour is what you are experiencing in your file handling.

If you use Binary mode access you should be able to get around this, though you'll have to do a little more work to parse your file into strings, etc.

For more on Binary mode, check out GavinO's File I/O Tutorial (http://www.visualbasicforum.com/showthread.php?t=123814) in the Tutors Corner.

cguygo
10-27-2004, 12:13 PM
thanks for the tip...i had considered the binary but as i am lazy today i was hoping for a quick fix but i think you are right. I better get back to it...

loquin
10-27-2004, 03:10 PM
As webbone implies, the ascii character 26 has been used as the end-of-file marker in text files for a long time. In fact, since long before DOS. (I know for a fact that it was used in CP/M text files in the 70's)

Really, if a file has a control-Z embedded in it, it's NOT a text file, no matter how much else of the file is purely text. You'll have to process it as a binary file.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum