0

I tried to use somekind of condition of another attribute object to set the attribute with pre-set enumeration values {"", "1","2","3"}, something like:

if ( o."attr1" = "AA" ) {
   o."enumeratedAttr" = "1"
} else if (o."attr1" = "BB" ) {
   o."enumeratedAttr" = "1"
} else {
   o."enumeratedAttr" = ""  //no change as default
}

However, as enumeration attribute return its element as DBE. My script above won't work. So How can I set/select one of enumeration values at each condition. Thanks.

1 Answers1

0

Okay, I'm going to take a crack at this, and I hope it is helpful.

if ( o."attr1" = "AA" ) {    
 o."enumeratedAttr" = "1" 
} else if (o."attr1" = "BB" ) {
 o."enumeratedAttr" = "1"
} else {
 o."enumeratedAttr" = ""  //no change as default }

This won't pull the enum as the type that you want. If you want to compare the Enum to a string, you'll need something like this:

if ( o."attr1" "" == "AA" ) {    
 o."enumeratedAttr" = "1" 
} else if (o."attr1" "" == "BB" ) {
 o."enumeratedAttr" = "1"
} else {
 o."enumeratedAttr" = ""  //no change as default }

You will need to make sure that you don't assign o."enumeratedAttr" to a value that isn't valid for the enum type - this will cause a DXL error.

Adding the quotes ( "" ) after the object / attribute call ensures that DOORS is doing a string to string comparison.

Russell Bregman
  • 436
  • 3
  • 8