scriptingibm-doors

How to make a DXL attribute that is true if the word "shall" exists in another attribute, in IBM Rational DOORS?


Trying to make a DXL boolean attribute (called "Is Requirement?") true if the word "shall" exists in another attribute (called "Text"), and otherwise false.

In edit-mode on the DOORS module, I click Edit -> Attributes -> "Is Requirement?" -> Edit... -> check DXL attribute -> Browse... -> New, write the code -> Ok, close all windows, Tools -> Refresh DXL Attributes

Object o
for o in current Module do{

 if((o."Text") contains "shall")
  {
   o."Is Requirement?" = "True"
  }
 else
  {
   o."Is Requirement?" = "False"
  }

}

Solution

  • Several aspects here:

    This changes your code to

    int offset, length
    bool matchCase = true
    obj.attrDXLName = findPlainText (obj."Object Text" "", "shall", offset, length, matchCase)
    

    Remember that the type of your DXL attribute must be boolean for this to work.

    And last but not least: Are you sure that your condition "Text contains shall" is sufficient? What about all the words that contain "shall" (https://www.thefreedictionary.com/words-containing-shall)? There are some threads about this topic somewhere in the internet. Search for "Requirement DXL shall shallow". And: is "shall" enough? What about "may", "should", "must"?