I still learn new things…

I have been writing Notes applications since late 1996/early 1997, and been a full time Notes developer since December 1997. But I still find out new things.
I have been using lists for several years now, and as you may know, the easiest way to loop though a list is to use the ForAll statement:

Dim mylist List As String 
mylist("1st") = "First list item" 

mylist("2nd") = "Second list item" 

ForAll

m In mylist 

Print ListTag(m) & " is " & m 

End ForAll 

 

Sometimes I have to loop through an array of unknown size, and in the past I would have done something like this:

Dim

myarray(1) As String 

Dim

i As integer 

myarray(0

) = "First array item"

myarray(1

) = "Second array item" 

For i = LBound(myarray) To UBound(myarray) 

Print i & " is " & myarray(i) 

Next 

 

But just a couple of weeks ago, I was wondering if perhaps I could use ForAll statement to koop through an array as well. I looked in the online help, and sure think, the help indicated that it was indeed possible:

Dim

myarray(1) As String 

myarray(0

) = "First array item" 

myarray(1

) = "Second array item" 

ForAll

m In myarray 

Print m 

End ForAll 

Shorter and you save a variable and a couple of function calls. I doubt it does much for actual code execution, but the code is cleaner and easier to read.

Hope this little tip can help someone!

 

Leave a Reply