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


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

Reading text files with cr / lf line terminators

From Dave Stratford <daves@orpheusmail.co.uk>
Subject Reading text files with cr / lf line terminators
Newsgroups comp.sys.acorn.programmer
Date 2012-08-07 09:05 +0100
Message-ID <52bb693e1fdaves@orpheusmail.co.uk> (permalink)
Organization Hexagon Systems Limited

Show all headers | View raw


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.

Any best practices?

Many thanks,

Dave

-- 
    _                     _________________________________________
   / \._._ |_  _     _  /'       Orpheus Internet Services
   \_/| |_)| |(/_|_|_> /          'Internet for Everyone'
_______ | ___________./       http://www.orpheusinternet.co.uk

Back to comp.sys.acorn.programmer | Previous | NextNext 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