• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 982
  • Last Modified:

Dynamic multi-dimension array in LotusScript

I need to loop through a document collection and store 7 field values form each document. I know that there will always be 7 fields, but the number of documents is determined at run time.  I tried dim TestArray(1 To x, 1 To 7), but this throws an error.  If I put a fixed number in place of variable x it work fine.  I also need to sort the array on field 1 after reading the document collection.
Can this be done in LotusScript?  Can anyone provide example code?

1 Solution
Hi Ed_CLP,
Sure, you dim first as dynamic, then when you know the bounds you redim.

Dim Session As New NotesSession
    Dim db As NotesDatabase
    Set db = session.currentdatabase
    Dim doc As NotesDocument
    Dim coll As NotesDocumentCollection
    Dim theList() As String
    Set coll = db.unprocesseddocuments
    If coll.count <1 Then Exit Sub
    Dim k As Long, n As Long
    n = 7
    k = coll.count
    Redim theList(0 To K, 1 To n) As String    
    k = 0
    Set doc = coll.getfirstdocument
    While Not doc Is Nothing        
        With doc
            Print "Processing " + Cstr(k)
        End With
        k = k+1
        Set doc = coll.GetNextDocument(doc)

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now