Finding cr Character in Lines read from a file???
Devin Asay
devin_asay at byu.edu
Fri Jun 29 11:26:52 EDT 2007
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?
Dave,
I think it's because you are looking at the *line*. Since cr is the
line delimiter, it is never included in the text of, say, 'line 3 of
myMultiLineVar'. Instead, look at the whole container:
repeat with myIndex = 1 to the length of myMultiLineVar
HTH,
Devin
Devin Asay
Humanities Technology and Research Support Center
Brigham Young University
More information about the use-livecode
mailing list