LOTUSSCRIPT/COM/OLE CLASSES
This script must include the file LSXLERR.LSS in order to use the Domino error constants.
Sub Initialize On Error lsERR_NOTES_DATABASE_NOTOPEN Goto logDbOpenError Dim currentLog As NotesLog Dim db As NotesDatabase Dim collection As NotesDocumentCollection Set currentLog = New NotesLog( "Ornithology Agent" ) Set db = New NotesDatabase( "", "" ) Call db.OpenMail Call currentLog.OpenFileLog( "c:\log.txt" ) Set collection = db.AllDocuments ' error might occur here Call currentLog.Close Exit Sub logDbOpenError: Call currentLog.LogError _ ( lsERR_NOTES_DATABASE_NOTOPEN, _ "Unable to open db " & db.FileName ) Resume Next End Sub
This script must include the file LSERR.LSS in order to use the LotusScript error constants.
Sub Initialize On Error ErrDivisionByZero Goto LogThisError Dim currentLog As New NotesLog( "Let's do division" ) Dim x As Integer, y As Integer, z As Integer Call currentLog.OpenMailLog _ ( "Joe Perron", "Division log" ) y = 9 z = 0 x = y / z ' error Call currentLog.Close Exit Sub LogThisError: Call currentLog.LogError( ErrDivisionByZero, _ Error$( ErrDivisionByZero ) ) Resume Next End Sub
In this case, the LogError method creates a new document in AGENTLOG.NSF. The document contains the following items:
A$PROGNAME "Let's do division" A$LOGTIME 10/25/95 04:42:24 PM A$USER "Kerry Bowling" A$LOGTYPE "Error" A$ERRCODE 11 A$ERRMSG "Division by zero"
The LogError method adds a new line of text to LOG.TXT. For example, LOG.TXT looks like this:
Let's do division: 10/25/95 04:49:51 PM: Error (11): Division by zero