Hi All,
Ii will be highly appreciated if someone can help out please??
I have some documents in a View, which were created against a Form. In this Form I have a Text Type multivalue field named 'T1"
I just want to write an Lotus Scriot agent to capture values in ‘T’ and check against another value in this form.
Can someone help me to do following in below agent please?
1.How do I assign values in T1 (T1 is multivalue text field int he document) into myDynamic array -‘’ myDynamic() = Doc.T1 ‘’’ ??
-
How do I calculate number of elements in myDynamic array, then I want assign ot to variable P – elems = ubound(myDynamic()
-
’ How do I print values in myDynamic Array ?? print myDynamic(J) ???
Sub Initialize
Dim S As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim Doc As NotesDocument
Dim myDynamic() As String
Dim P As Integer
Dim Elems As Integer
Set S = New NotesSession
Set db = S.CurrentDatabase
Set view1 = db.GetView("Chan_View1")
Set Doc = View1.GetFirstDocument
While Not (Doc Is Nothing )
''' How do I assign values in T1 (T1 is multivalue text field int he document) into myDynamic array -'' myDynamic() = Doc.T1 ''' ??
'' How do I calculate number of elements in myDynamic array, then I want assign ot to variable P -- elems = ubound(myDynamic())??
For J=1 To P
' How do I print values in myDynamic Array ?? print myDynamic(J) ????
j = j + 1
Next
Wend
End Sub
Subject: Dynamic Array Help??
Mira,
Here is the answers , ( If i understand correctly )
1- Transferring T1 field data into dynamic array ,
Dim arrT1() as string
Dim count as integer
Dim item as NotesItem
count=0
set item=doc.getFirstItem("T1)
Redim preserve arrT1(count)
forall vals in item.values
arrT1(count)=vals
count=count+1
end forall
If you want to keep unique and other logic put your check inside loop.
2- Count dynamic array data
Ubound(arrT1)
3- Printing ,
For i=0 to ubound(arrT1)
print arrT1(i)
next i
So if you combine everything in program , it should come something like ,
Dim session as new notessession
Dim db as notesdatabase
Dim doc as notesdocument
Dim view as notesview
Dim item as notesitem
Dim arrT1() as string
Dim count as integer
set db=session.currentdatabase
set view=db.getview(“view1”)
count=0
Redim preserve arrT1(count)
Set doc = view.getfirstdocument
While not doc is nothing
set item= doc.getfirstitem(“T1”)
Forall items in item.values
arrT1(count)=items
count=count+1
End forall
set doc = view.getNextdocument(doc)
Wend
To print,
For i=0 to ubound(arrT1)
print arrT1(i)
next i
Cheers,
Rishi
Subject: It stops at line - arrT1(count)=vals - Error “Subscript out of Range”
Hi Rishi,List doesn’t have duplicates…
Thank you for your response,
I did run your code as below:
When I debug and check it stops at line >> arrT1(count)=vals
With a message as " Subscript out of Range"??
Sub Initialize
Dim S As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim Doc As NotesDocument
Dim P As Integer
Dim arrT1() As String
Dim count As Integer
Dim item As NotesItem
count=0
Set S = New NotesSession
Set db = S.CurrentDatabase
Set view1 = db.GetView("Chan_View1")
Set Doc = View1.GetFirstDocument
While Not (Doc Is Nothing )
Set item=doc.getFirstItem("T1A")
Redim Preserve arrT1(count)
Forall vals In item.values
arrT1(count)=vals ''''' Program stops here!!!!!!!! "Subscript out of Range???
count=count+1
End Forall
P=Ubound(arrT1)
Print count
Print P
For i=0 To Ubound(arrT1)
Print arrT1(i)
Next i
Wend
End Sub
Subject: RE: It stops at line - arrT1(count)=vals - Error “Subscript out of Range”
Oops, I kept redim outside forall loop … keep inside ,should be
Set item=doc.getFirstItem(“T1A”)
Forall vals In item.values
Redim Preserve arrT1(count)
arrT1(count)=vals
count=count+1
End Forall
Rishi
Subject: You Beauty!! It works Rishi
Thank you so much Rishi, It works very fine now…Cheers
Mira
Subject: RE: Dynamic Array Help??
Mira,
However this way you ends up with duplicate values in array which need to be filtered again. I would suggest use LIST. Here is the sample for that which will only keep unique vals …
Dim listT1 List as String
set item = doc.getfirstitem(“T1”)
forall items in item.values
If Not Iselement(listT1(items)) Then
listT1(items)=items
end forall
to Print list val,
Forall T in listT1
print T
end forall
Cheers,
Rishi