Page 1 of 1

styling lines of a field dynamically

Posted: Thu Oct 23, 2014 12:55 am
by Da_Elf
This code works. If there is someone who knows an easier way to do it please share. Until then if this helps anyone then feel free to use it.
I created it since there was never the same amount of lines between titles to uniformly choose a line number to style

Code: Select all

on mouseUp
   put empty into fooditems
   put 1 into titlearraycount
   repeat for 5 times
      put "This is a title" & return after fooditems
      put the number of lines in fooditems into listTitles[titlearraycount]
      add 1 to titlearraycount
      put "this is some text" & return after fooditems
      put "this is some more text" & return after fooditems
      put "this will finish it" & return after fooditems
      put "-------------------------" & return after fooditems
   end repeat
   set the text of fld "A" to fooditems
   repeat for each element deline in listTitles
      set the textSize of line deline of fld "A" to "22"
      set the textStyle of line deline of fld "A" to "bold"
   end repeat
end mouseUp

Re: styling lines of a field dynamically

Posted: Wed Oct 29, 2014 5:26 pm
by MaxV
Here is my way:

Code: Select all

put "<h1>This is a title</h1><font size=22>this is some text<br>this is some more text<br>this will finish it</font><br>-------------------------" into temp
set the htmlText of field "A" to temp
just 2 lines. 8)

Re: styling lines of a field dynamically

Posted: Thu Oct 30, 2014 3:50 am
by Da_Elf
Yes.. this has been a learning experience. At least I'm learning

Re: styling lines of a field dynamically

Posted: Thu Oct 30, 2014 2:08 pm
by [-hh]
Hi Da_Elf,

good idea to "serialise" this. There is another advantage of your method:
You created a 'numbering system' of the entries with that.
I changed the second part of your script slightly to show what I mean.

Code: Select all

on mouseUp
  put empty into fooditems
  put 1 into titlearraycount
  repeat for 5 times
    put "This is a title" & return after fooditems
    put the number of lines in fooditems into listTitles[titlearraycount]
    add 1 to titlearraycount
    put "this is some text" & return after fooditems
    put "this is some more text" & return after fooditems
    put "this will finish it" & return after fooditems
    put "-------------------------" & return after fooditems
  end repeat
  lock screen; lock messages
  put fooditems into fld "A"; set textsize of fld "A" to 14
  put the keys of listTitles into kk; sort kk numeric
  repeat for each line k in kk
    put listTitles[k] into deline
    put "[" & k &"]" & space before line deline of fld "A"
    set textStyle of line deline of fld "A" to "bold"
    set textSize of line deline of fld "A" to "22"
    -- put item (1+ k mod 5) of "green,red,cyan,gray,yellow" into tc
    -- set textColor of first word of line deline of fld "A" to tc
    -- set backcolor of line deline of fld "A" to tc
    -- set backColor of first word of line deline of fld "A" to "black"
  end repeat
  unlock screen; unlock messages
end mouseUp