Dynamic multi-dimension array in LotusScript

Posted on 2006-03-23
Last Modified: 2013-12-18
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?

Question by:Ed_CLP
    1 Comment
    LVL 18

    Accepted 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)


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
      In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    This video discusses moving either the default database or any database to a new volume.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now