conditional formatting, how to do it

Alex Tweedly alex at tweedly.net
Fri Jan 2 18:41:46 EST 2009


Ignoring all the other serious issues, I noticed :

Rob Cozens wrote:
>
>> I change this so as to do the formatting as follows:
>>
>> set the itemDelimiter to " "
>> repeat for each line theLine in field "test" of stack "Calendar"
>> if item 1 of theLine is "Sunday" then
>> set the textStyle of theLine to "bold"
>> end if
>> end repeat
>>
>>
....
> BTW, one can skip setting the itemDelimiter by substituting
>
>         if word 1 of theLine is "Sunday" then
>
> or
>
>         if offset("Sunday ",theLine) = 1 then
>
> your if statement.
>
Actually, neither of those is equivalent to the original version (though 
it may be that either one is closer to what the orignal question intended).

If the text line (t) contains a TAB followed by "Sunday " followed by 
SPACE then
   item 1 of t      has     TABSunday
   word 1 of t    has     Sunday
whereas if the line has "Sunday" followed by TAB followed by SPACE, then
   item 1 of t      has     SundayTAB
   offset("Sunday", t)  has   1

so in both cases there is a text line which produces different results.

(Which is a shame - my suggestion was going to be
     if theLine begins with "Sunday" then ....
but that also has a subtly different meaning.)

-- Alex.




More information about the Use-livecode mailing list