次の例は、ユーザーがタイマーを使用不可にしていないかぎり、文書が開かれてからの経過時間を保持して報告します。この例はいくつかのスクリプトで構成されます。
Dim elapsedTime As Integer
Dim elapsedTimer As NotesTimer
%INCLUDE "lsconst.lss"
Sub Postopen(Source As Notesuidocument)
Dim session As New NotesSession
Set elapsedTimer = session.CreateTimer()
elapsedTimer.Interval = 1
elapsedTimer.Comment = _
"Elapsed time since opening document"
elapsedTime = 0
On Event Alarm From elapsedTimer _
Call elapsedTimerHandler
End Sub
Sub elapsedTimerHandler(Source As NotesTimer)
elapsedTime = elapsedTime + 1
End Sub
Sub Click(Source As Button)
Dim etime As Integer
Dim minutes As Integer
etime = elapsedTime
If etime < 60 Then
Messagebox etime & " second(s)",, _
"Elapsed time since opening document"
Else
minutes = 0
Do While etime > 59
minutes = minutes + 1
etime = etime - 60
Loop
Messagebox minutes & " minute(s), " & _
etime & " second(s)",, _
"Elapsed time since opening document"
End If
End Sub
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