conditional formatting, how to do it

Mark Smith lists at futilism.com
Fri Jan 2 12:27:15 EST 2009


Peter, in the "repeat for each" structure, the loop variable -  
"theLine" - is just that, a variable, so when you try to format it,  
nothing happens to the line in the field of which it's a copy (and  
you get an error, because you can't format text in a variable this  
way, and in any case, you shouldn't try to modify the loop variable  
in a 'repeat for').

Eric's approach will work,:

set the itemDelimiter to " "
repeat for each line theLine in field "test" of stack "Calendar"
   add 1 to tLineNumber
   if item 1 of theLine is "Sunday" then
     set the textStyle of line tLineNumber of fld "test" of stack  
"Calendar" to "bold"
   end if
end repeat

you could also use htmlText:

set the itemDelimiter to " "
repeat for each line theLine in field "test" of stack "Calendar"
   add 1 to tLineNumber
   if item 1 of theLine is "Sunday" then
     put "<p><b>" & theLine & "</b></p>" & cr after tHtmlText
   else
     put "<p>" & theLine & "</p>" after tHtmlText
   end if
end repeat

set the htmlText of fld "test" of stack "Calendar" to tHtmlText

Best,

Mark


On 2 Jan 2009, at 16:55, Peter Alcibiades wrote:

> Must be doing something obvious wrong.  As usual!  I want to go  
> through a
> field and format lines depending on what they start with.
>
> So to begin with I try the following, which works just fine, to  
> make sure the
> lines are being found and picked up:
>
> set the itemDelimiter to " "
> repeat for each line theLine in field "test" of stack "Calendar"
> if item 1 of theLine is "Sunday" then
> put theLine
> end if
> end repeat
>
> Now 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
>
> and get the error
>
> Message execution error:
> Error description: Chunk: error in object expression
>
> So how to do this?  That is, make every line that starts with  
> Sunday bold?
> And why is it not working?
>
> Peter
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the Use-livecode mailing list