首页 Domino LotusScript脚本代码集
文章
取消

Domino LotusScript脚本代码集

Try/Catch错误处理
code try:
'set up error handler
On Error Goto catch

Goto finally
catch:
'log error
'Msgbox Erl & ":" & Error
MsgBox LSI_Info(2) & " called by " & LSI_Info(12) & "(" & LSI_Info(430) & "): " & Error$ & " - Line: " & CStr(Erl)
'resume to the final thing
Resume finally

finally:
'do the final thing code

Option Public
Option Declare
Sub Initialize
'set up error handler
On Error Goto catch

'变量定义
Dim s As New NotesSession'当前进程
Dim dbCur As NotesDatabase'当前数据库
Dim collection As NotesDocumentCollection'选中文档的集合
Dim doc As NotesDocument'处理的文档

'变量初始化
Set dbCur = s.CurrentDatabase
Set collection = dbCur.UnprocessedDocuments

Set doc = collection.GetFirstDocument'获得第一个要处理的文档
While Not doc Is Nothing'当集合中没有要处理的文档时退出
'处理文档

'获得下一要处理的文档
Set doc = collection.GetNextDocument(doc)
Wend

Goto finally
catch:
'log error
Msgbox Erl & ":" & Error
'resume to the final thing
Resume finally

finally:
'do the final thing
Exit Sub'不抛出错误
End Sub

链接:
LSI_Info: obscure but useful information in LotusScript

本文由作者按照 CC BY 4.0 进行授权