Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Enumerations in DXL Scripts?

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
}
like image 947
h0b0 Avatar asked Aug 30 '11 08:08

h0b0


2 Answers

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.

like image 58
h0b0 Avatar answered Oct 27 '22 22:10

h0b0


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"

like image 38
Steve Valliere Avatar answered Oct 28 '22 00:10

Steve Valliere