We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Dynamic multi-dimension array in LotusScript

Ed_CLP
Ed_CLP asked
on
Medium Priority
993 Views
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?

Thanks
Comment
Watch Question

Commented:
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)
    Wend

Regards!

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.