Formatting help needed

Ken Ray kray at sonsothunder.com
Thu Dec 23 14:28:11 EST 2004


On 12/23/04 12:57 PM, "Lynch, Jonathan" <BNZ2 at CDC.GOV> wrote:

> If you are setting the htmltext, then don't you need to use <p> </p> or
> <br> to create returns and linefeeds?

Yes, you need to put "<p>" in front of each line, and "</p>" at the end of
each line, and use <BR> when you want a blank line. Also, in examining your
code you can use (&&) for "concatenate with a space between" instead of (& "
" &), and I noticed you had overlapping tags (<b><i></b></i>) which is a
no-no (the should be paird from the inside out, like  <b><i></i></b>).

So after it was fixed it would be:

on preOpen
  set the useUnicode to true
  set the textFont of field "Glyph" to "Aboriginal Sans,unicode"
  set the textFont of field "Display" to "Aboriginal Sans,english"
  set the htmlText of field "Display" to "<p><i>" & \
     the htmltext of field "POS" && the htmltext of field \
     "pronounce" & "</i></p>" & return & \
     "<p>" &  the htmltext of field "Definitions" & "</p>" & \
     return & "<p><b><i>example</i></b></p>" & \
     return & "<p><i>" & the htmlText of field "example" & \
     "</i></p>" & return & "<BR>" & return & \
     "<p><b><i>see also</i></b></p>" & return & \
     "<p><i>" & the htmlText of field "xref1" & ", " & \
      the htmlText of field "xref2" & "</i></p>"
end preOpen

Another method I use is to put the "<p></p>" in *after* the fact. So while
I'm building the html string, I'm just using returns (I use "CR" instead of
"return" because it is shorter), and then use "replace" on it just before I
send it to where I want it, like this:

on preOpen
  set the useUnicode to true
  set the textFont of field "Glyph" to "Aboriginal Sans,unicode"
  set the textFont of field "Display" to "Aboriginal Sans,english"
  put "<i>" & the htmltext of field "POS" && the htmltext of field \
     "pronounce" & "</i>" & CR & the htmltext of field \
     "Definitions" & CR & "<b><i>example</i></b>" & CR & \
     "<i>" & the htmlText of field "example" & "</i>" & CR & \
     CR & CR & "<b><i>see also</i></b></p>" & CR & \
     "<i>" & the htmlText of field "xref1" & ", " & \
      the htmlText of field "xref2" & "</i>" into tHTML
  replace CR with "</p><p>" in tHTML  -- takes care of all "inner" CRs
  put "<p>" & tHTML & "</p>" into tHTML
  set the htmlText of fld "Display" to tHTML
end preOpen

HTH,

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list