Formatting columns across a list item

Richard Gaskin ambassador at fourthworld.com
Fri Feb 25 18:40:58 EST 2005


Karen wrote:
> Hi,
> 
> I'm trying to use Revolution to build a program to track stock tickers.  The
> wrinkle to this is that I'd like the movement in a stock to be red or green
> according to whether it was negative or positive.
> 
> I've successfully built a static version that allows the user to enter up to
> 10 items, and as the fields are all labels I can format them as necessary.
> This is fine as far as it goes, but is a problem if the user wants to track
> more than 10 stocks.
> 
> My next thought was to use a scrollable list, which would allow as many
> stocks as the user likes.  However, with the standard Revolution lists it
> appears that they can only have a single text colour across all the columns
> for a given item.  I think I must be missing something here, because I'm
> presuming that there is a way to do this in Revolution?
> 
> The idea is to have:
> Stock name              Price       Change
> 
> Where the stock name and price would be black text, and the change would
> vary according to the direction the stock is going in.

You can use htmlText to assign colors, either by mnemonic name or by 
numeric values -- assuming your list is tab-delimited for display in the 
columnar list you could do something like this (off the cuff, but should 
be close):


on DisplayList pList
   put empty into tHtmlText
   set the itemdel to tab
   repeat for each line tLine in pList
     get item 3 of tLine
     if it > 0 then put tLine&"<br>" after tHtmlText
     else
       put item 1 to 2 of tLine &tab& \
         "<font color="&quote&"red"&quote&">"& item 3 of tLine \
         &"<br>" after tHtmlText	
   end repeat
   put tHtmlText into fld "Display"
end DisplayList



-- 
  Richard Gaskin
  Fourth World Media Corporation
  ___________________________________________________________
  Ambassador at FourthWorld.com       http://www.FourthWorld.com


More information about the use-livecode mailing list