Genii Weblog


Civility in critiquing the ideas of others is no vice. Rudeness in defending your own ideas is no virtue.


Fri 9 Sep 2005, 04:22 PM
In the midst of testing for Notes/Domino 7, I have been finalizing some new samples for the Midas Rich Text LSX.  One is the Color code LotusScript and Formula language sample, which I use quite often when posting code.  In a self-referential kind of move, here is the code in the Color code LotusScript agent.  Pretty handy for posting samples on forums:


Sub Initialize
   ' *** Domino front-end classes
   Dim ws As New NotesUIWorkspace
   Dim uidoc As NotesUIDocument
 
   ' *** Domino front-end classes
   Dim session As New NotesSession
   Dim db As NotesDatabase
   Dim doc As NotesDocument
   Dim unid As String
   Dim mode As Integer
 
   Dim flag As Variant
   Dim textfrom As String
 
   Set db = session.CurrentDatabase
   Set uidoc = ws.CurrentDocument
   mode = uidoc.EditMode
   Set doc = uidoc.Document
 
   On Error Goto ErrorHandler
   Dim rtitem As New GeniiRTItem
   Dim rtchunk As GeniiRTChunk
 
   ' *** 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(|'*|+Chr(0))
 
      rtitem.HighlightFont = "Blue"
      Call rtchunk.HighlightMatching("", db.FilePath, "LotusScript Reserved Words", "ReservedWord", "", "MinLength=2")
      Call rtchunk.HighlightText("=")
      Call rtchunk.HighlightText("(")
      Call rtchunk.HighlightText(")")
      Call rtchunk.HighlightText("&")
      Call rtchunk.HighlightText(",")
      rtitem.Save
      Set uidoc = ws.EditDocument(mode, doc)
   End If
   Exit Sub   
ErrorHandler:
   Print "Error is& Cstr(Err) & "(& Cstr(Error(Err)) & ")"
   Resume Next
End Sub

Copyright © 2005 Genii Software Ltd.