ibm-doorsreadxl

Loop through a project to open read-only view for a specific module


I am new to dxl and I could not find on the internet what I am looking for. I am able to open a module in read-only mode using:

module m = read("D/Fruits/ColorRed/Apples") //Where Project fruits, contains many folders Like ColorRed, ColorYellow, and in Color Red folder there are modules like apples, Cherries, Strawberries etc. which I would like to access

But If I am only given the project name i.e. Fruits. Then how do I loop through the folders and modules inside and open for example Apples in read-only mode?

I have tried out the following code but it does not work,

Here's what I have tried,

string MODULE_NAME = "Apples"
string PROJECT_NAME = "Fruits"

Module mod = null
for mod in PROJECT_NAME do (
   if (mod.name == MODULE_NAME)(
     read(mod.name)
    )
)

Solution

  • Check the DXL manual at https://www.ibm.com/docs/en/SSYQBZ_9.7.0/com.ibm.doors.requirements.doc/topics/dxl_reference_manual.pdf, chapter 16 "Rational DOORS hierarchy", about the different loops available. I think you will need the loop "for all items in project", which has the operation "Assigns itemRef to be each successive undeleted item (for which the user has read access) in project, looping recursively through contained folders and projects.". In your case this would be

    string MODULE_NAME = "Apples"
    string PROJECT_NAME = "Fruits"
    
    Project p = project "/" PROJECT_NAME
    Item itemRef
    Module mod = null
    
    for itemRef in p do {
     // print fullName(itemRef) "\n"
     if (name (itemRef) == MODULE_NAME) {
       mod = read (fullName itemRef)
     }
    }
    
    if (!null mod) {
       …do something with the module…
       close (mod)
    }