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


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

Re: EOF Marker

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!news.cgarbs.de!news.addix.net!feed.news.schlund.de!schlund.de!news.online.de!not-for-mail
From "Theo Tress" <rbk@online.de>
Newsgroups comp.lang.basic.visual.misc
Subject Re: EOF Marker
Date Fri, 20 Jan 2012 17:45:46 +0100
Organization 1&1 Internet AG
Lines 31
Message-ID <jfc5pr$2sg$1@online.de> (permalink)
References <VVDMq.171568$6J7.5729@newsfe08.ams2>
NNTP-Posting-Host dslb-094-217-081-120.pools.arcor-ip.net
Mime-Version 1.0
Content-Type text/plain; format=flowed; charset="iso-8859-1"; reply-type=response
Content-Transfer-Encoding 7bit
X-Trace online.de 1327078011 2960 94.217.81.120 (20 Jan 2012 16:46:51 GMT)
X-Complaints-To abuse@einsundeins.com
NNTP-Posting-Date Fri, 20 Jan 2012 16:46:51 +0000 (UTC)
In-Reply-To <VVDMq.171568$6J7.5729@newsfe08.ams2>
X-Priority 3
X-MSMail-Priority Normal
X-Newsreader Microsoft Windows Mail 6.0.6002.18197
X-MimeOLE Produced By Microsoft MimeOLE V6.0.6002.18463
Xref x330-a1.tempe.blueboxinc.net comp.lang.basic.visual.misc:710

Show key headers only | 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