Reputation: 21
I’m working on a project with more or less 50 modules and thousands objects for module.
I need to modify the “inherit from parent” field on some objects of each module.
The one way I found to do it is to open each module and run the following dxl script I did… obviously, open all modules is a crazy solution!!!
/*
** Set_Inherit_Attribute_FALSE ***
Remove flag from the attribute "Inherit from Parent"
on each object of each module of the project
*/
// Variable definition
Object o
Module m
string serr
// file name provided by DOORS containing the results
string filename = tempFileName
print "FILE CONTAINING RESULTS - " filename "\n"
// open file in write mode
Stream outputLog = write filename
// Set current project
Project prj = current Project
print "PROJECT - "(name prj) "\n"
outputLog << "-------------------- PROJECT " (name prj) " --------------------\n\n"
// Management of each module in the project
for m in prj do {
// write in outputLog the MODULE name
outputLog << "\n**************** MODULE " (name m) " ****************\n"
// set the "inherited" to false
for o in entire m do {
// The "Inherited" has to be updated just for NOT LEAF object
if (!leaf(o)){
// write in outputLog the obj id modified
outputLog << "OBJ ID " (identifier o) "\n"
serr = specific(o)
// Check if the set of "inherited" failed
if (!null serr){
// inform the user and stop the execution
outputLog << "OBJECT ERROR"
ack "ERROR INHERITED"
// close outputLog
close outputLog
halt
}
}
}
// save modificiation on module m
save m
}
// close outputLog
close outputLog
// Inform the user the execution is ended
ack "EXECTUTION COMPLETED"
Is there a way to do the same modification without open all modules?
Thanks.
Upvotes: 0
Views: 2360
Reputation: 111
The loop 'for m in prj do' will act only on modules that you have previously opened manually in the DOORS graphical user interface.
To solve that, my modification of your code (below) loops through all items (folders, projects, formal and link modules) in each project, and opens any formal modules it finds for itself. It's important to close modules after processing, to free memory, so my modification does that, too.
/*
** Set_Inherit_Attribute_FALSE ***
Remove flag from the attribute "Inherit from Parent"
on each object of each module of the project
*/
// Variable definition
Item i
Object o
Module m
string serr
// file name provided by DOORS containing the results
string filename = tempFileName
print "FILE CONTAINING RESULTS - " filename "\n"
// open file in write mode
Stream outputLog = write filename
// Set current project
Project prj = current Project
print "PROJECT - "(name prj) "\n"
outputLog << "-------------------- PROJECT " (name prj) " --------------------\n\n"
// Management of each module in the project
for i in prj do {
if (type(i) == "Formal")
{
m = edit(fullName(i), false)
// write in outputLog the MODULE name
outputLog << "\n**************** MODULE " (name m) " ****************\n"
// set the "inherited" to false
for o in entire m do {
// The "Inherited" has to be updated just for NOT LEAF object
if (!leaf(o)){
// write in outputLog the obj id modified
outputLog << "OBJ ID " (identifier o) "\n"
serr = specific(o)
// Check if the set of "inherited" failed
if (!null serr){
// inform the user and stop the execution
outputLog << "OBJECT ERROR: " serr
ack "ERROR INHERITED"
// close outputLog
close outputLog
halt
}
}
}
// save modificiation on module m
save(m)
close(m)
}
}
// close outputLog
close outputLog
// Inform the user the execution is ended
ack "EXECUTION COMPLETED"
Also, note that your 'for o in entire m do' loop (quote from the DXL reference manual):
Assigns the variable o to be each successive object in module regardless of its deleted state or the current display set. It includes table and row header objects and the cells.
Are you sure this is what you intend?
Upvotes: 1
Reputation: 426
In order to modify an object, you do have to open the module. In this case, I would be focused on closing modules after they have been checked to minimize memory load.
/*
** Set_Inherit_Attribute_FALSE ***
Remove flag from the attribute "Inherit from Parent"
on each object of each module of the project
*/
// Variable definition
Object o
Module m
string serr
// file name provided by DOORS containing the results
string filename = tempFileName
print "FILE CONTAINING RESULTS - " filename "\n"
// open file in write mode
Stream outputLog = write filename
// Set current project
Project prj = current Project
print "PROJECT - "(name prj) "\n"
outputLog << "-------------------- PROJECT " (name prj) " --------------------\n\n"
// Management of each module in the project
for m in prj do {
// write in outputLog the MODULE name
outputLog << "\n**************** MODULE " (name m) " ****************\n"
// set the "inherited" to false
for o in entire m do {
// The "Inherited" has to be updated just for NOT LEAF object
if (!leaf(o)){
// write in outputLog the obj id modified
outputLog << "OBJ ID " (identifier o) "\n"
serr = specific(o)
// Check if the set of "inherited" failed
if (!null serr){
// inform the user and stop the execution
outputLog << "OBJECT ERROR"
ack "ERROR INHERITED"
// close outputLog
close outputLog
halt
}
}
}
// save modificiation on module m
save m
Module close_mod = m
close ( close_mod )
}
// close outputLog
close outputLog
// Inform the user the execution is ended
ack "EXECTUTION COMPLETED"
If you look above, I added:
Module close_mod = m
close ( close_mod )
inside the for m in proj loop. If you ran close(m), the DXL loop would throw an error the next time it tried to assign the 'm' variable. So you end up having to declare a separate module handle and running close against that.
This should keep your memory more manageable. I would also consider running the whole thing via an 'eval_' statement, but that may not be needed.
Upvotes: 0