Genii Weblog

Color coding LotusScript

Thu 23 Dec 2004, 11:43 PM



by Ben Langhinrichs
To follow up on my Color coding formula language, I thought I should include the color coding agent I use for formula language.  I'll also put it out in a separate database soon, because you are missing a crucial ingredient here.  That is list of 336 reserved words.  Rather than putting in a whole slew of HighlightText calls for each keyword, I use our HighlightMatching method, which simply looks in a view, pulls out each keyword and then highlights it.  To handle another language, such as Java, would be a trivial case of populating its own set of reserved words.  Note that the HighlightMatching method does distinguish between words and parts of words, so only whole words are highlighted.

Again, this logic is not very robust, but it is a heck of a quick and easy way to color code LotusScript (but you need to have our Midas Rich Text LSX).

' *** Connect to Body field and perform highlight  ****
Call rtitem.ConnectBackend(doc.Handle, "Body", False)
 
rtitem.CacheLinkMatching = True
If rtitem.IsConnected Then
   If mode Then uidoc.Save
   uidoc.Close
   Set rtchunk = rtitem.DefineChunk("Everything")
   rtchunk.TextWildcards = True      
   rtitem.HighlightFont = "DarkGreen"
   Call rtchunk.HighlightText(|'*|)
 
   rtitem.HighlightFont = "Blue"
   Call rtchunk.HighlightMatching("", "ColorCode.nsf", "LS Words", "ReservedWord", "", "MinLength=2")
   Call rtchunk.HighlightText("=")
   Call rtchunk.HighlightText("(")
   Call rtchunk.HighlightText(")")
   Call rtchunk.HighlightText("&")
   Call rtchunk.HighlightText(",")
   rtitem.Save
End If

Copyright © 2004 Genii Software Ltd.

What has been said:

No documents found