Pages

Monday, January 7, 2008

Get the literal label of an enum value

I couldn't find a function in the standard to give me the literal label (@SYSxxxx) of an enum value, so I came up with this prototype:

static void literalLabelsFromEnum(Args _args)
{  
    #Properties         
    SysDictEnum sysDictEnum = new SysDictEnum(enumNum(SysDimension));  
    TreeNode    treeNode;  
    int         x;     
    ;
     
    for (x = 0; x <= SysDictEnum.lastValue(); x++) 
    {           
        treeNode = TreeNode::findNode(sysDictEnum.path() + '\\' + sysDictEnum.index2Symbol(x));           
        print sysDictEnum.index2Label(x)+ '  ' + findProperty(treeNode.AOTgetProperties(),#PropertyLabel);     
    }     
    pause;
}