LOTUSSCRIPT /COM/OLE のクラス


例:Intersect メソッド
次の例は、名前に「Ex.」という文字列を含む「example」エージェントから成る文書コレクションをビルドします。まず、データベース内のすべてのエージェントから成る、nc という文書コレクションをビルドします。次に、NotesDatabase Agents プロパティを使用してエージェント名をチェックします。続いて、nc の Note ID を使用して、新規コレクション ncEx をビルドします。そして、ncExnc との共通部分に基づいて、目的のコレクションを作成します。Intersect メソッドのパラメータには、NotesCollection を指定します。作成したコレクションはファイル filename にエクスポートします。

Sub Initialize
 Dim session As New NotesSession
 Dim db As NotesDatabase
 Dim stream As NotesStream
 Dim exporter As NotesDXLExporter
 Dim nc As NotesNoteCollection
 Dim ncEx As NotesNoteCollection
 Dim filename As String
 
 REM Create note collection from the current database
 Set db = session.CurrentDatabase
 path$ = "c:\dxl\"
 filename$ = Left(db.FileName, Len(db.FileName) - 3) & "dxl"
 filename$ = path$ & filename$
 Set nc = db.CreateNoteCollection(False)
 nc.SelectAgents = True
 Call nc.BuildCollection
 If nc.Count = 0 Then
   Messagebox "No agents in " & db.Title
   Exit Sub
 End If
 Messagebox Cstr(nc.Count) & " agents in database"  , , db.Title
 
REM Create a collection of "example" agents
 Set ncEx = db.CreateNoteCollection(False)
 Call ncEx.BuildCollection
 Dim nid As String
 nid = nc.GetFirstNoteId
 Forall a In db.Agents
   REM look for example agents
   If Not findTest(a.Name)(0) = 0 Then
     Call ncEx.Add(nid)
   End If
   nid = nc.GetNextNoteId(nid)
 End Forall
 
 Call nc.Intersect(ncEx)
 
REM Export note collection as DXL
 Set stream = session.CreateStream
 If Not stream.Open(filename) Then
   Messagebox "Cannot open " & filename,, "Error"
   Exit Sub
 End If
 Call stream.Truncate
 Set exporter = session.CreateDXLExporter(nc, stream)
 Call exporter.Process
 Messagebox Cstr(nc.Count) & " examples output"  , , filename
 
End Sub

Function findTest(value As String)
 findTest = Evaluate( "@Contains (""" _
 + Ucase$(value) _
 + """; """ _
 + "EX."+""") ")
End Function

関連項目