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


Groups > comp.sys.acorn.programmer > #2005

Re: Reading text files with cr / lf line terminators

From Ron <beeb@woosh.co.nz>
Newsgroups comp.sys.acorn.programmer
Subject Re: Reading text files with cr / lf line terminators
Date 2012-08-07 23:35 +1200
Organization -
Message-ID <13697cbb52.beeb@ron1954.woosh.co.nz> (permalink)
References <52bb693e1fdaves@orpheusmail.co.uk>

Show all headers | View raw


In message <52bb693e1fdaves@orpheusmail.co.uk>
          Dave Stratford <daves@orpheusmail.co.uk> wrote:

> Hi folks,
> 
> have a small basic prog that reads text files. I use line$=GET$#file% to
> read each line.
> 
> This is okay on RiscOS generated files, but when I read a PC/Dos created
> file where each line ends in crlf I end up getting two lines, one with
> data, one blank.
> 
> A quick and dirty check showed me that GET$# can use both cr and lf as
> line terminators, so when they are both there it sees two lines.
> 
> What's the best way of trapping this instance, particularly as it's
> possible that there will sometimes be genuinely valid blank lines.
> 
> I'm guessing that I either read the whole file into a block of memory and
> frig it using indirection operators, or I read it byte at a time and try
> and determine from that.
> 
> Problem with any of these techniques of course is when the line
> terminators are not consistent.
> 

Yes, then what would be a simple job becomes something else.
The indirection operator only recognises CHR$(13) as the terminator
for a string, if you can rely on that.

I've been playing with serial terminals and there is a variation
of line terminations there also.
Reading a character at a time, I guess a flag will need to be set
to check the next character for the existence of a second terminator.

Ron M. 

Back to comp.sys.acorn.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Reading text files with cr / lf line terminators Dave Stratford <daves@orpheusmail.co.uk> - 2012-08-07 09:05 +0100
  Re: Reading text files with cr / lf line terminators Vince M Hudd <vinceh@softrock.co.uk> - 2012-08-07 12:11 +0100
    Re: Reading text files with cr / lf line terminators Vince M Hudd <vinceh@softrock.co.uk> - 2012-08-07 12:26 +0100
      Re: Reading text files with cr / lf line terminators Dave Stratford <daves@orpheusmail.co.uk> - 2012-08-07 14:52 +0100
  Re: Reading text files with cr / lf line terminators Ron <beeb@woosh.co.nz> - 2012-08-07 23:35 +1200
    Re: Reading text files with cr / lf line terminators Alan Adams <alan@adamshome.org.uk> - 2012-08-07 14:21 +0100
      Re: Reading text files with cr / lf line terminators Jeremy Nicoll - news posts <jn.nntp.scrap007@wingsandbeaks.org.uk> - 2012-08-07 15:09 +0100
      Re: Reading text files with cr / lf line terminators Ron <beeb@woosh.co.nz> - 2012-08-08 03:01 +1200
        Re: Reading text files with cr / lf line terminators Ron <beeb@woosh.co.nz> - 2012-08-08 04:13 +1200
  Re: Reading text files with cr / lf line terminators Jeremy Nicoll - news posts <jn.nntp.scrap007@wingsandbeaks.org.uk> - 2012-08-07 15:20 +0100
  Re: Reading text files with cr / lf line terminators jgh@arcade.demon.co.uk (Jonathan Graham Harston) - 2012-08-08 22:41 +0100

csiph-web