Search code examples
ibm-doors

How to fetch enum attributes using AttrBaseType


I want to fetch enum attributes in a module using AttriBaseType and print it's elements.

Basically I want to know the usage of AttriBaseType in dxl.


Solution

  • For retrieving enum values, if you really want to use it explicitly, you can do it perhaps like this:

    AttrType at
    for at in current Module do {
        print (at.name) " -- " (at.type) "\n"
        AttrBaseType abt = at.type
        if (abt == attrEnumeration) {
            print "it is an " abt "\n"
            int enumCount = at.size
            int index
            for (index = 0; index < enumCount; index++) {
                // value, related number
                print at.strings[index] ", " at.values[index] "\n"
            }
            print "\n"
        }
    }