Alternating rows in a list

Gordon Tillman got at mindspring.com
Wed Apr 20 01:29:10 EDT 2005


Howdy Varen,

About your post:

> I'm trying to format a list field which displays plain old html with a 
> list of links. I'd like to format the list so that each link in the 
> list is an alternating color such as white, light grey, white, light 
> grey, etc.....

Here is an example which may get you started..

Given a simple stack with one card that has two fields on it:

(1) field "htmlFld" that displays the information, and
(2) field "entryFld" where you can enter sample HTML to play with.


Field "entryFld" has the following script:

on enterInField
   set the htmlText of field "htmlFld" to me
end enterInField

And I entered the following into field "entryFld":

<font color="black">Line 1
<li><font color="green">Line 2
<li><font color="blue">Line 3

When you hit enter with the cursor in field "entryFld", then field 
"htmlFld" displays this:

Line 1
Line 2
Line 3

The first line is black, the second line is green, and the third line 
is blue.


OK, here is another idea...

Given a card with a field that contains the list of data to colorize, 
this script will set the colors to alternate:

on mouseUp
   local tColor1, tColor2, tLastColor
   put "blue" into tColor1
   put "green" into tColor2
   put tColor1 into tLastColor
   local tLine
   repeat with tLine = 1 to the number of lines of field 1
     set the textColor of line tLine of field 1 to tLastColor
     if tLastColor is tColor1 then put tColor2 into tLastColor
     else put tColor1 into tLastColor
   end repeat
end mouseUp

--gordon


More information about the use-livecode mailing list