dev.kanngard.net make sure you visit my new blog at: johankanngard.net

Iterator classes in LotusScript

by Johan Känngård / [LotusScript] / 2002-09-21 / #47


The Iterator is a convenience class to loop through a set of elements. Related to the Enumeration class (Java folks know what I mean :-). The ArrayIterator is used to loop through a LotusScript array, like this:

Dim a(0 To 4) As String
a(0) = "Test 0"
a(1) = "Test 1"
a(2) = "Test 2"
a(3) = "Test 3"
a(4) = "Test 4"
Dim iterator As New ArrayIterator(a)
Do While iterator.hasNext()
	Print iterator.next()
Loop

You have to put the attached code in a script library, and put %INCLUDE "lserr.lss" in (Options).

Attached is also the EmptyIterator class, that can be used to return an Iterator from a method, which chould not have any elements in it.



Floppy icon Iterator.ls1 Kb
Floppy icon EmptyIterator.ls0 Kb
Floppy icon ArrayIterator.ls1 Kb