Usage Information - Enumerations
Enumerations are wrapped by ImportTypeLib. They can be used to retrieve constant values which can for example be passed to methods.
Retrieving a constant
The syntax for this is quite easy:
const := lib.Enum.Field
Parameter
Field |
The name of the constant to retrieve, as defined. If the field names begins with the type name followed by an underscore, this can be omitted:
value := lib.TreeScope.TreeScope_Children value := lib.TreeScope.Children
|
Returns
The returned
const
is the integer defined in the enumeration.
Throws
If the given field name is unknown, if the variable pointed to by the field name is not constant (shouldn't happen in an enumeration) or if any other failure occurs during retrieval, an exception is thrown.
Enumerating an enumeration
Enumerations support enumeration of their members, which means they can be used with a
for
-Loop.
enumObj := lib.Enum._NewEnum()
for field, value in lib.Enum
{
}
Parameter
field |
Receives the full name of the constant member (including a potential type prefix).
|
value |
Receives the (integer) value of the constant.
|
Returns
The object returned by
_NewEnum()
is of course an enumerator object as described
in the AutoHotkey_L help.
Throws
If the enumeration process encounters any error, an exception is thrown. However, this process is only done one times, so if the first enumeration succeeds, subsequent calls won't error either.
Setting a constant
Trying to set a member of an enumeration will result in an exception.