lineoffset doesn't find empty lines
Jim Ault
jimaultwins at yahoo.com
Sun Aug 16 19:15:48 EDT 2009
On Aug 16, 2009, at 3:52 PM, Brian Yennie wrote:
> Keep in mind that all of these (cr&cr) methods will miss an empty
> line as the FIRST line. So you need to do something like:
>
> function emptyOffset tText
> if (char 1 of tText is cr) then return 1
> else return lineOffset(cr&cr, tText)+1
end emptyOffset
OR you could do
put cr & cr into cr2
return lineoffset( cr2, (cr2 & tText & cr2) )
Of course make the adjustment based on the correction for the number
of lines in tText
You will know that line 1 and line -1 will always be empty.
Be careful of using
word 1 to wod -1 of tText since this trims chars that are consider
word delimiters
item 1 to -1 of tText that considers all chars part of the item
string, including spaces
Ahh, the joys of chunking expressions.
Jim Ault
Las Vegas
More information about the use-livecode
mailing list