Examples: Intersect method (NotesNoteCollection - LotusScript®)
This example builds a note collection of "example" agents, agents with the text "Ex." in the name. First build a notes collection nc of all agents in the database. Next, using the NotesDatabase Agents property, check the agent name. Using the note ID from nc, build a new collection, ncEx. Use the intersection of ncEx with nc to get the desired collection. A NotesCollection is used as the Intersect method parameter. The collection is exported to the file 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