By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,101 Members | 1,387 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,101 IT Pros & Developers. It's quick & easy.

How to read "binary" file sequentially?

P: 1
Hi!! I have a question here where I used :
Expand|Select|Wrap|Line Numbers
  1. Open sourceDir & sourceFile For Input As af
  2. Do While Not EOF(af)
  3.  
  4.     Line Input #af, textline
  5.  
  6.     If Trim(textline) Like "fruits" Then
  7.         list_start = True
  8.     End If
  9.  
  10. Loop      'loop while not end of file
  11. Close #af 'close file
but the problem is that the whole file is read into textline instead of line by line, how can i change the file so that I'll be able to capture line by line?
(Opening the file using textpad and notepad produces different format, textpad will open it with line by line while notepad shows the whole file in a string) Thx a lot!!!!
Mar 28 '07 #1
Share this Question
Share on Google+
2 Replies


Dököll
Expert 100+
P: 2,364
Hey there buzzy!

There are a number of posts here on this very subject, some posted by me. Please search a little deeper, see what pops up. Try adding strGetWords to your search if you need to see something I have posted. I must caution, and this something I became aware of through hours of research, when you are reading from a text file, you will likely be reading a word within a word, whereby rain is found in train:-) Of course, if you are after a different medium, you should be ok with the code as is...

Good luck!

Dököll
Mar 28 '07 #2

Expert 5K+
P: 8,434
Your file has the wrong delimiter characters at the end of each line. In the DOS/Windows world, it should have two characters - CR (Carriage Return, ASCII code 13) and LF (Line Feed, ASCII code 10). Generally just referred to as CRLF. It probably has just one or the other (CR or LF). This is common with files coming from other operating systems, such as Unix.

One quick and relatively simple way to correct the file is to open it in MS Word and save it again as plain text. Word will (probably) put in the proper delimiters.
Mar 28 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.