Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.basic.visual.misc > #710

Re: EOF Marker

From "Theo Tress" <rbk@online.de>
Newsgroups comp.lang.basic.visual.misc
Subject Re: EOF Marker
Date 2012-01-20 17:45 +0100
Organization 1&1 Internet AG
Message-ID <jfc5pr$2sg$1@online.de> (permalink)
References <VVDMq.171568$6J7.5729@newsfe08.ams2>

Show all headers | View raw


> Got a bit of code that reads a text file, looks something like this:
>
> Open FilePath For Input As #FileNum
>    Do Until EOF(FileNum)
>    Line Input #FileNum, LineStr
>    DoSomething
>    Loop
> Close #FileNum


Text lines om a.txt file usually are separated by a two byte sequence CR-LF 
= carriage return - linefeed = cgr$(13) chr$(10) and the end of such a file 
is indicated by am EOF character - chr$(26).

Basic's Line Input reads until such a CR/LF sequence is encountered, and 
sets EOF to true if an EOF char occurs.

So if yo try to read a file including control characters and binary data 
(and not plain text) there is a good chance that your program encounters an 
EOF char and stops reading.

If that's your problem then you must do a binary read (OPEN ... FOR BINARY 
...)providing an input buffer of fixed length and check the CR/LF yourself. 
If a CR/LF occurs you can shorten the buffer and start next reading behind 
the CR/LF position else you have to read one more buffer.

Doing this, you can also read (and write) 'behind' the EOF char easily.

HTH
rokas 

Back to comp.lang.basic.visual.misc | Previous | NextPrevious in thread | Find similar


Thread

EOF Marker "Ivar" <ivar.ekstromer000@ntlworld.com> - 2012-01-03 14:04 +0000
  Re: EOF Marker "Auric__" <not.my.real@email.address> - 2012-01-03 15:05 +0000
    Re: EOF Marker "Ivar" <ivar.ekstromer000@ntlworld.com> - 2012-01-03 16:05 +0000
  Re: EOF Marker GS <gs@somewhere.net> - 2012-01-03 13:04 -0500
  Re: EOF Marker "Theo Tress" <rbk@online.de> - 2012-01-20 17:45 +0100

csiph-web