Domino Code Fragment

Code Name*
LotusScript Classes - Examples
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.17.184.90
Description*
Demonstrates how to create and use a class called DisplayMsg
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
While this is a simple example, you might easily imagine additional possibilities here. The message may actually be "displayed" on a pager, or logged to a database, all by adding more code to this basic structure. The mechanism to create the object, load its properties and call its methods remains the same.
Files/Graphics attachments (if applicable): Code:
LotusScript Classes - Examples


The following example creates a class, called DisplayMsg, to display a message. The DisplayMsg class will have a property called Text and a method called Display. The text for the class is entered into the declarations of Notes form.

Class DisplayMsg
    'Declare member variables in a LotusScript class
    mMsg As String
    mMsgNumber As Integer
   
    Public Property Set Text As String
         mMsg = Text
    End Property
   
    Public Sub Display
         Msgbox(mMsg)
    End Sub    
End Class


The code in the next listing is entered into the Sub Click event of a button on this Notes form. Here you will see a variable created as a variant called objMsg, which will be used to hold the instance of our message object. The set objMsg = New DisplayMsg line actually creates the instance of the object and loads a reference of it into the objMsg variable.

Sub Click(Source As Button)
    Dim objMsg As Variant
    Set objMsg = New DisplayMsg
    objMsg.Text = "(" & Format$(68) & ") - " & Error$(68)
    objMsg.Display
    Delete objMsg
End Sub


Once you have created the object, you can set the text property by referring to it as object.property, or objMsg.Text in this case. You can cause the code in the Display method (function) to execute using the same process.