EnumConst Procedure

Version 11

 

 

Returns the enum constant name, description or value.

 

Syntax

[ vrReturn ] EnumConst ( sEnumTypeName, lConstValueOrIndex, [enConstEnumInfo] )

The EnumConst procedure syntax has the following parts:

 

Name

Type

Description

vrReturn

Variant

Returned name string, description string or value (long).

sEnumTypeName

BString

Enum type name.

lConstValueOrIndex

Long

Value or Index of enum constant to return its name, description or value.

enType

[Val] enumEnumConstInfo

The type of information is needed and the way the constant is located. See comments.

Where

enumEnumConstInfo can be one of the following:

 

Name

Value

Description

aEnumConstByValue

0

lConstValueOrIndex should specify the value of the constant.

aEnumConstByIndex

1

lConstValueOrIndex should specify the index (0-based) of the constant within the enum.

aEnumConstName

2

Return the constant name (string).

aEnumConstDescription

4

Returns the constant description (string).

aEnumConstValue

8

Returns the constant value (long).

Comments

The function can be used to retrieve information about enum type constants name or description.

The function returns empty variant if lConstValueOrIndex is not found as one of the constants of the specified enum type.

enType can be a combination of one of aEnumConstByValue or aEnumConstByIndex and, one of aEnumConstName, aEnumConstDescription or aEnumConstValue.

Example

The following example prints name and description of aclrBlue that belongs to enumAColor:

 

! disables Exception Dialog for abnormal errors

clr=aclrBlue

print EnumConst("enumAColor", clr)

print EnumConst(typeof clr, clr, aEnumConstByValue or aEnumConstName)

print EnumConst("enumAColor", clr, aEnumConstByValue or aEnumConstDescription)

print str(EnumConst(typeof clr, aclrBlue, aEnumConstByValue or aEnumConstValue), 16)

for i=0 to 1000

    vr=EnumConst(typeof clr, i, aEnumConstByIndex or aEnumConstName)

    if VarType(vr)=vtEmpty then exitloop

        print vr; \

        " - ";EnumConst(typeof clr, i, aEnumConstByIndex or aEnumConstdescription); \

        ", ";str(EnumConst(typeof clr, i, aEnumConstByIndex or aEnumConstValue), 16)

next

The above example prints:

 

aclrBlue
aclrBlue
Blue
ff0000
aclrBlack - Black, 0
aclrWhite - White, ffffff
aclrRed - Red, ff
aclrGreen - Green, ff00
aclrBlue - Blue, ff0000
aclrYellow - Yellow, ffff
aclrMagenta - Magenta, ff00ff
aclrCyan - Cyan, ffff00
aclrGray - Gray, 808080
aclrLightGray - Light Gray, c0c0c0
aclrDarkRed - Dark Red, 80
aclrDarkGreen - Dark Green, 8000
aclrDarkBlue - Dark Blue, 800000
aclrLightBrown - Light Brown, 8080
aclrDarkMagenta - Dark Magenta, 800080
aclrDarkCyan - Dark Cyan, 808000
aclrActiveBorder - Active Border, 8000000a
Active Title Bar - Active Title Bar, 80000002
aclrActiveTitleBarText - Active Title Bar Text, 80000009
aclrApplicationWorkspace - Application Workspace, 8000000c
aclrButtonFace - Button Face, 8000000f
Button Highlight - Button Highlight, 80000014
aclrButtonShadow - Button Shadow, 80000010
aclrButtonText - Button Text, 80000012
aclrDesktop - Desktop, 80000001
aclrDisabledText - Disabled Text, 80000011
aclrHighlight - Hightlight, 8000000d
Highlighted Text - Highlighted Text, 8000000e
aclrInactiveBorder - Inactive Border, 8000000b
aclrInactiveTitleBar - Inactive Title Bar, 80000003
aclrInactiveTitleBarText - Inactive Title Bar Text, 80000013
aclrMenuBar - Menu Bar, 80000004
aclrMenuText - Menu Text, 80000007
aclrScrollBars - Scroll Bars, 80000000
Window Background - Window Background, 80000005
aclrWindowFrame - Window Frame, 80000006
aclrWindowText - Window Text, 80000008

See Also

typeof, nameof, descof