reading from a file

Alex Tweedly alex at tweedly.net
Sun Jun 12 14:14:45 EDT 2005


Jon wrote:

> Alex recommended "read from file tName until cr".  Is this the 
> prefered approach, or should it be "until return"?  I'm not sure which 
> is the most portable approach.
>
> :)

Jon,

You need to read the Doc entry for "return" very carefully.
Then have a large cup of espresso, and then read it again.  
(substitute your local equivalent to espresso; here in Scotland it's 
hard to find a good cup of coffee, so I usually choose Lagavullin Malt 
Whisky instead :-)

'cr' is a constant - equivalent to the constant 'return' and equivalent 
to the constant 'lf'
they are all equivalent to   numtochar(10)

i.e. CR is not the ascii carriage return character, commonly called "cr".

If you read (or write) a file having specified "text" mode in the open 
statement, the native line ending (LF on Unix, carriage return on OSX, 
CRLF on Windows) is translated on the fly into the Rev standard which is 
CR (or any of the synonyms as above).

So - assuming I have understood it all properly, and I'm on about my 
fifth reading of this part of the docs today :-), what I used in the 
earlier email is the most portable way to do it - but even it is still 
vulnerable to files which been copied from other systems in binary mode 
and hence have preserved the "wrong" line endings.

-- 
Alex Tweedly       http://www.tweedly.net



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.6.8 - Release Date: 11/06/2005



More information about the use-livecode mailing list