Carapace

Enumerator Class

This Enumerator wraps up the COM interface IEnumVARIANT which is supported by many COM objects when they want to expose a sequence of items.

Within Carapace script there is the for looping function. The most common use of this function is to iterate over a List. However, it can also be used to iterate over an enumeration.

For example, suppose we have a COM object called bookshelf which has a property called books and that this property is a collection of names of books. (ie. it supports the IEnumVARIANT interface). We can then iterate over every book as follows:

    (for book bookshelf.books

        (print book)
    )

Enumerator Creation

An enumerator is created by getting a COM property which offers IEnumVARIANT or invoking a COM method which returns such an interface.

Enumerator Properties

None.

Enumerator Methods

method name description
length count the no. of items in the enumeration
reset reset the enumeration back to the start
forward move forward along the enumeration by the supplied number of elements
current return the current element in the enumeration without moving onto the next
next return the current element in the enumeration and move onto the next


length

Count the no. of items in the enumeration.

Arguments: none

Return type: Integer


reset

Reset the enumeration back to the start.

Arguments: none

Return type: the empty List () is returned.


forward

Move forward along the enumeration by the supplied number of elements.

Arguments:

nToSkipInteger

Return type: the empty List () is returned.


current

Return the current element in the enumeration without moving onto the next .

Arguments: none

Return type: the return type depends on what types the enumeration contains -- potentially, any type could be returned.


next

Return the current element in the enumeration and move onto the next .

Arguments: none

Return type: the return type depends on what types the enumeration contains -- potentially, any type could be returned.


Contents Index Current topic: COM Related Links: COM helpers, objects, built-in objects