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)
)
An enumerator is created by getting a COM property which offers IEnumVARIANT or invoking a COM method which returns such an interface.
| 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 |
lengthCount the no. of items in the enumeration.
Arguments: none
Return type: Integer
resetReset the enumeration back to the start.
Arguments: none
Return type: the empty List () is returned.
forwardMove forward along the enumeration by the supplied number of elements.
Arguments:
| nToSkip | Integer |
Return type: the empty List () is returned.
currentReturn 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.
nextReturn 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 |