Looping / Validating Question

Hello

I have a small question which I cannot solve with Lotus Script. In PHP it would be fairly easy.

Basically I’m looping through a document collection. Each document is checked for a few items. Now if document B has different items then the previous document A (just one is enough to be different) then it will perform an action.

In PHP I would for each new loop check if the current items combination is already in an array. If so, then it would go for the next loop, if not then I would add it to the “check” array and perform the other action.

However I don’t know how to do that in Lotus Script. How I can increase the outbound of a dynamic array and how to check if a value is already in existance in this check array.

Subject: Looping / Validating Question

You could use my Vector class at:http://dev.kanngard.net/Permalinks/ID_20020506204851.html

or you could use it like this (in a somewhat trivial example :-):

Dim array As Variant

Dim i As Integer

Redim array(0 To 0) as String

For i = 1 to 1000

If i Mod 10 = 0 Then

Redim Preserve array(Lbound(array) To Ubound(array) + 10)

End If

a(i) = i * i

Next i

  • Johan

johan@kanngard.net

http://dev.kanngard.net

Subject: RE: Looping / Validating Question

I didn’t read your entire question :-)To check if a value already is in the array, you have to loop through the array and check every value… This can also be done more easily with my Vector class.

  • Johan

johan@kanngard.net

http://dev.kanngard.net

Subject: RE: Looping / Validating Question

“To check if a value already is in the array, you have to loop through the array and check every value”

No, you don’t, not any more – there’s ArrayGetIndex. And there’s the List type to use instead of an array when you need a dynamic container; it can be checked with IsElement. (Nothing against your Vector, Johan; I’m just pointing out the native option to the newbie.)

Subject: RE: Looping / Validating Question

Stan, you’re quite right! I missed those! :smiley: Time to use them instead!!!

  • Johan

johan@kanngard.net

http://dev.kanngard.net

Subject: RE: Looping / Validating Question

Thank you for your quick reply. I will have a look at your class :slight_smile: