It's all about the answers!

Ask a question

How do i load the current module and then iterate through objects to get its name (DOORS DXL)


Arjuna Pandu (113) | asked Jul 17 '23, 9:55 a.m.
edited Jul 17 '23, 10:02 a.m.
Hello



i'm trying to fetch the content of all the artifacts in a module (current stream), i want to do it using the path of the module.

Im using below statements to read a module.
string modFullName = "\\Training\\myFolder\\test"
Module m = read(modFullName,true);
Module m = edit(modFullName, true);

above statement wont help me in looping through objects of m.

If i have a baseline
Baseline base = baseline(majVersion,minVersion,suff)
Module m = load(base,true)
then for loop works fine.

how do i load the current version of the module using a path?

regards
Arjuna





2 answers



permanent link
haseeb alam (91) | answered Jul 17 '23, 3:34 p.m.
Hi Arjuna,

You can use the object function along with the null keyword to access the module object.
Ex:
string modFullName = "\\Training\\myFolder\\test"
Object modObj = null

// Find the module object using its full name
if (null(object(modFullName))) {
    print "Failed to find the module: " modFullName
} else {
    modObj = object(modFullName)
    Module m = module(modObj)

    Object obj
    for obj in entire m do {
        // Access the name of each object
        string objName = obj."Object Text"
        print "Object Name: " objName
    }
}

To explain:
 object(modFullName) is used to find the module object with the given full name. 
If the module object is found, you can create a Module instance using module(modObj)
Then, you can iterate through the objects in the module using a for loop and access the name of each object using obj.Object Text.

I hope it helps you

Comments
Arjuna Pandu commented Jul 18 '23, 6:36 a.m.
I'm getting below error
-E- DXL: <Line:2> incorrect arguments for function (object)
-E- DXL: <Line:2> incorrectly concatenated tokens
-I- DXL: All done. Errors reported: 2. Warnings reported: 0.

I'm trying for the module which is present in the below location.
string modFullName = "\\Training\\test\\template"
Object modObj = object(modFullName)

permanent link
haseeb alam (91) | answered Jul 20 '23, 10:00 a.m.
try this
string modFullName = "\\Training\\test\\template"
Module m = read(modFullName, true)

if (null m) {
    print "Failed to read the module: " modFullName
} else {
    Object obj
    for obj in entire m do {
        // Access the name of each object
        string objName = obj."Object Text"
        print "Object Name: " objName
    }
}

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.