Finding cr Character in Lines read from a file???

Dave dave at looktowindward.com
Fri Jun 29 11:33:52 EDT 2007


On 29 Jun 2007, at 16:26, Devin Asay wrote:

>
> On Jun 29, 2007, at 9:06 AM, Dave wrote:
>
>> Hi,
>>
>> I have a file that has "cr" (0x0D) terminators on each line.
>>
>> If I have the line in "myLine" and do this:
>>
>> repeat with myIndex = 1 to the length of  myLine
>> if char myIndex of myLine = cr then
>> --do something at end of line
>> end if
>> end repeat
>>
>> It never finds the cr. I looked in the file and conformed that the  
>> lines end in a single cr character.
>>
>> When I did a charToNum() on cr is returns 0x0A which is a lf!!!!!
>
> Internally in Rev, all line delimiters are LF, showing Rev's unix  
> heritage. When Rev writes a text file to disk, it converts the line  
> delimiter to whatever is the convention for the host OS--ASCII 13  
> for Mac, ASCII 13 + 10 for Win, and ASCII 10 for *nix. Conversely,  
> when it reads text files, it converts line delimiters to ASCII 10.
>>
>> What gives? How can I find the real cr is a variable?

It's because I'm not reading the file with RunRev, it's coming in via  
an external I've written to get around the >2GB File Limit problem in  
RunRev.

So, how can I get the *Real* Value of cr??

In the real code, I have a ReadUntil() function, this takes a  
character parameter for the "until" character. The function is  
defined like so:

function ReadUntil theFileForkRef,theUntilChar, at theDataBuffer

and I call it like so:

put ReadUntil(myFileForkRef,cr,myDataBuffer) into myOSStatus

Thanks a lot
All the Best
Dave




More information about the use-livecode mailing list