text colors

Malte Brill revolution at derbrill.de
Sun Aug 13 03:40:06 EDT 2006


HI Liam,

the problem with your original script was that repeat for each works  
different from ordinary repeat loops. Repeat for each uses an  
indexvariable that is read only (tLine in your case). tLine is not a  
numeric reference to a line, but the contents of that line, so your  
script would not work.

so if your fld would contain

Tomato
Mango
Mungo

tLine would contain "Tomato" in the first iteration of the loop,  
"Mango" in the second and "Mungo" in the last (without the quotes).  
Repeat for each executes a whole lot faster than the other forms of  
repeat, so I tend to use it whenever possible. You do not have a  
direct reference to a line number though.
However, you could still take advantage of the faster execution of  
repeat for each by introducing a counter variable.

put 0 into tCounter
repeat for each line tLine in fld "booking"
   add 1 to tCounter
   if "reservation" is in tLine then
     set the textColor of line tCounter of fld "booking" to red
   end if
end repeat


Hope that helps,

Malte



More information about the use-livecode mailing list