Pergunta

I'd like to test the value of an enumeration attribute of a DOORs object. How can this be done? And where can I find a DXL documentation describing basic features like this?

if (o."Progress" == 0) // This does NOT work
{
  // do something
}
Foi útil?

Solução

So after two weeks and an expired bounty I finally made it. Enum-Attributes can be assigned to int or string variables as desired. But you have to assign to a variable to perform such a conversion. It is not casted when a mere comparison is done like in my example. So here comes the solution:

int tmp = o."Progress"
if (tmp == 0)
{
  // do something
}

When tmp is a string, a comparison to the enum literals is possible.

That was easy. Wasn't it? And here I finally found the everything-you-need-to-know-about-DXL manual.

Outras dicas

You can also do

if(o."Progress" "" == "0")
{
   //do something
}

This will cast the attribute value to a string and compare it to the string "0"

For multi-valued enumerations, the best way is if (isMember(o."Progress", "0")) {. The possible enumerations for single and multi-enumeration variables are considered strings, so Steve's solution is the best dxl way for the single enumeration.

If you're talking about the "related number" that is assignable from the Edit Types box, then you'll need to start by getting the position of the enumeration string within the enum and then retrieve EnumName[k].value .

I'm no expert at DXL, so the only way to find the index that I know of off the top of my head is to loop over 1 : EnumName.size and when you get a match to the enumeration string, use that loop index value to retrieve the enumeration "related number."

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top