LOTUSSCRIPT/COM/OLE CLASSES


Examples: CreateTimer method
This example maintains and reports the elapsed time since a document is opened, unless the user disables the timer. The example has several scripts.

1. These declarations are in the (Globals) (Declarations) script for the form. The variable elapsedTime is used by various objects on the form. The NotesTimer object elapsedTimer must be in effect during the execution of a number of scripts on the form.


2. When a document based on this form opens, the NotesTimer object is created with an interval of one second. An event handler for the Alarm event of the object is established.
3. This user sub is the event handler specified in the On Event statement above. It simply increments the global variable by 1 each time it is called.
4. This script is for a button on the form. The script displays the time accumulated in the global variable.
5. This example queries the Enabled property of the NotesTimer object and toggles it if the user wants to.

Sub Click(Source As Button)
 If elapsedTimer.Enabled Then
   If Messagebox _
   ("Do you want to disable the timer?", _
   MB_YESNO + MB_ICONQUESTION, _
   "Elapsed timer is enabled") = IDYES Then
     elapsedTimer.Enabled = False
   End If
 Else
   If Messagebox _
   ("Do you want to enable the timer?", _
   MB_YESNO + MB_ICONQUESTION, _
   "Elapsed timer is disabled") = IDYES Then
     elapsedTimer.Enabled = True
   End If
 End If
End Sub

See Also