【问题标题】:Use/select enumeration values in DXL DOORS在 DXL DOORS 中使用/选择枚举值
【发布时间】:2017-09-19 05:02:55
【问题描述】:

我尝试使用另一个属性对象的某种条件来设置具有预设枚举值 {"", "1","2","3"} 的属性,例如:

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

但是,作为枚举属性,将其元素作为 DBE 返回。我上面的脚本不起作用。那么如何在每个条件下设置/选择一个枚举值。谢谢。

【问题讨论】:

    标签: scripting enumeration ibm-doors


    【解决方案1】:

    好的,我将对此进行破解,希望对您有所帮助。

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

    这不会将枚举作为您想要的类型。如果你想将 Enum 与字符串进行比较,你需要这样的东西:

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

    您需要确保没有将 o."enumeratedAttr" 分配给对枚举类型无效的值 - 这将导致 DXL 错误。

    在对象/属性调用之后添加引号 ( "" ) 可确保 DOORS 进行字符串与字符串的比较。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多