How to display values of a mutli valued enum attribute

Hi all,
I am looking for a dxl script which displays the filled in values of a multi valued enumeration attribute. I know the use of isMember function; but it is useful to check whether certain value is filled for that attribute.

For Ex:
if(isMember(obj."Test Status", "Pass")) is used to check whether "Pass" has filled in for attribute "Test Status". I am looking for a script which displays all values. For ex: Test status contains "Pass", "Fail", "Not Tested" then script shall display all three values.

Any help will be greatly appreciated.

Thanks in Advance
Ashok Anumula
ashokanumula - Thu Feb 16 02:12:08 EST 2012

Re: How to display values of a mutli valued enum attribute
SystemAdmin - Thu Feb 16 04:14:59 EST 2012

print (current Object)."my multi value attribute" ""

 


will print out the selected values separated by \n

 

 

 

Value 1
Value 2
Pass
Fail

 

 

Re: How to display values of a mutli valued enum attribute
llandale - Thu Feb 16 14:09:22 EST 2012

[1] isMember() is for reading an obj-attr value for precision; "+=" for setting with precision:

// Make sure "Unfinshed" is marked when "Testing" is already marked
if (isMember(obj.NameMultiAttr, "Testing")) then obj.NameMultiAttr += "Unfinished"
      // Make sure "Unfinshed" is removed when "Complete" is selected
if (isMember(obj.NameMultiAttr, "Complete")) then obj.NameMultiAttr -= "Unfinished"


[2] Normal attribute value access is used for gross reading and gross setting:

 

if (obj.NameMutliAttr "" = "") then obj.NameMultiAttr = "Unfinished"
print identifier(obj) "\tSelected values are:\t" (obj.NameMultiAttr) "\n"


[3] I think you are asking how to find out what ARE the valid enumerations. That has nothing to do with "Objects" nor "Values". Here's some old code:

 

 

//*************
int    fCountAT(Module mod, string NameAT)
{     // Count the number of legal values in the enumerated
        // Attribute Type; return the size if legal or -1 if not.
 
        AttrType        at
        int             Count
 
        at = find (mod, NameAT)
        if (!null at and at.type == attrEnumeration)
             Count = at.size
        else Count = -1
 
//        print "fCountAT: " NameAT " is a >" at.type "< size: " count "\n"
 
        return(Count)
}     // end fCountAT()
 
//***************
int     fGetListAT(Module mod, string NameAT, string List[])
{     // Get the list of legal values for the enumerated attribute and store them in the List array.
        // Do not over-fill List.
        // Return the number of stored values.
        // List could be defined as "string List[fCountAT(..)]
        // Note that if NameAT is not enumerated or has no values,
        //      0 is returned (the number of stored values)
 
        int     i
        int     SizeAT
        int     SizeList
        AttrType        at
 
        SizeAT          = fCountAT(mod, NameAT)
        SizeList        = sizeof(List)
 
        if (SizeAT > SizeList) 
           SizeAT = SizeList    // List not big enough; reduce AT size to that of the List.
        //   print "fGetListAT; NameAT/SizeAT/List = '" NameAT "'   " SizeAT "   " SizeList "\n"
        if (SizeAT > 0)
        {             // NameAT is valid Enumerated attribute
           at   = find (mod, NameAT)
           if (!null at)
           {  for (i=0; i<SizeAT; i++)
              {  List[i] = at.strings[i]
              //   print "\t>" List[i] "<"\t" SizeAT "\n"
        }
        else SizeAT = 0         // Is -1 if illegal enum attr, reset to zero
        return(SizeAT)
}     // end fGetListAT()
 
//********************
int     fCountAD(Module mod, string NameAD, string &NameAT)
{     // Count the number of enumerated values of the Enumerated Attribute NameAD.
        // Update the name of the associated Attribute Type.
        // If its not Enumerated, return -1.
        // Note: NameAT could reasonably used in subsequent calls to fGetListAT()
 
        int             Count = -1
        AttrDef         ad
        AttrType        at
 
        NameAT = ""
 
        ad     = find(mod, NameAD)
        if (null ad)
        {  return(Count)
        }
        NameAT = ad.typeName
        at     = find(mod, NameAT)
        if (!null at and at.type == attrEnumeration)
           Count = at.size
        return(Count)
}    // end fCountAD()
//Sample Use.  Get the size, declare the string array to hold values, populate the array
 
int     g_Count_DestDisc        = fCountAD(g_mPlanning, c_NamePlan_Disc, g_NameType_DestDisc)
string  g_Enums_DestDisc[g_Count_DestDisc],
fGetListAT(g_mPlanning, g_NameType_DestDisc, g_Enums_DestDisc)
int i
print "Enumerations for '" c_NamePlan_Disc "':\n"
for (i=0; i<g_Count_DestDisc; i++)
{  print "\t" g_Enums_DestDisc[i] "\n"
}


-Louie