Convert A Notesdocumentcollection To An Array Of Notesdocuments
This will Convert a NotesDocumentCollection to an Array of NotesDocuments.
Sometimes we have a need to process two document collections as one list. This
will allow you to do that. First convert to an array with this script, then
combine the arrays. This example uses references to my my "Examples" database
in the code.
SCRIPT LIBRARY
-------------------------------------------
'CollectionToArray:
Option Public
Dim i As Integer
Dim doc As NotesDocument
Dim n As Integer, sorted As Integer
Dim s1, s2 As String
Dim docs() As NotesDocument
Sub CollectionToArray(col As NotesDocumentCollection, docs() As NotesDocument)
n = col.count
Redim docs(n-1) As NotesDocument
For i = 0 To (n-1)
Set docs(i) = col.GetNthDocument(i+1)
Next
End Sub
EXAMPLE BUTTON 'CLICK' EVENT
---------------------------------------------
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim dt As New NotesDatetime("")
query = |Form = "Example"|
Set db = session.CurrentDatabase
Set dc = db.Search(query, dt, 0)
Print |There are | & dc.Count & | documents in the collection|
If dc.Count > 0 Then
Call CollectionToArray(dc, docs() )
Print |There are | & Ubound(docs) + 1 & | Documents in the new array|
Else
Print "No Documents Selected"
End If