reading from a file

Jon jbondy at sover.net
Sun Jun 12 14:30:08 EDT 2005


Alex:

Good to know that "CR" and "RETURN" are the same thing, and not 
necessarily a carriage return <sick grin>.  I guess so long as Rev 
manages to substitute the locally correct value, I don't really care.  
Still, wouldn't it have been smarter to use Pascal parlance, and call it 
EOL (end of line). 

Sigh.   So much convoluted history.

:)

Jon


Alex Tweedly wrote:

> 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.
>


More information about the use-livecode mailing list