Hi all, |
Re: How to display values of a mutli valued enum attribute print (current Object)."my multi value attribute" ""
Value 1 Value 2 Pass Fail
|
Re: How to display values of a mutli valued enum attribute [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"
if (obj.NameMutliAttr "" = "") then obj.NameMultiAttr = "Unfinished" print identifier(obj) "\tSelected values are:\t" (obj.NameMultiAttr) "\n"
//*************
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"
}
|