Genii Weblog

Method of the day: AppendParagraph

Fri 2 Feb 2007, 12:20 PM



by Ben Langhinrichs
A while back, I posted Method of the Day: AppendHotspot and  Method of the Day: ReplaceText and considered turning it into a regular series like the Rich Text 101 series (see the right hand panel on my blog for that series), but time got away from me.  But a question in our Support forum from a Midas user made me realize that there is a method I use a lot that was not properly documented in our Help database, the AppendParagraph method.  

Like many methods in our Midas Rich Text LSX, the AppendParagraph method packs a lot of punch into a single method.  Not only can you add a paragraph, you can set the styles for the paragraph, set the initial font, color and styles for the text in the paragraph, and even add a hide-when formula while you are at it.  When I was building samples for my SpeedGeeking session on layers, I used this extensively, since it makes it ewasy to set up a paragraph to look and act the way you want in one concise call.  For example, setting up the animated progress bar, I used the following code snippet:

For=To 100
   Call rtchunk.AppendParagraph("", "Plain 10pt Black", "p!="+Cstr(i))
   If i > 10 Then
      Call rtchunk.AppendLayer("150px", "100px", "100px",Cstr((443*i)/100)+"px", 1, |LayerHTMLID='L'+Cstr(i) BackgroundImage='lssubbanner.jpg' BackgroundRepeat='once' Text='|+Cstr(i)+|%' TextFont='Arial Bold 18pt Blue' |, "Above='Single' Justify='Center' ")
   Else
      Call rtchunk.AppendLayer("150px", "100px", "100px",Cstr((443*i)/100)+"px", 1, |LayerHTMLID='L'+Cstr(i) BackgroundImage='lssubbanner.jpg' BackgroundRepeat='once' |, "")
   End If
Next   
Call doc.ReplaceItemValue("p", 0)
rtitem.Save


For each loop, I added a paragraph with a slightly different hide-when formula, then added a layer with content (and its own paragraph style).  Imagine how much harder this would be with the Notes rich text classes, even if they did allow you to create the layer.

Copyright © 2007 Genii Software Ltd.

What has been said:

No documents found