How do i load the current module and then iterate through objects to get its name (DOORS DXL)
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
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
}
}
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
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.
-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)
Object modObj = object(modFullName)
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
}
}