Dxl looping only through open modules?

I have a script that loops through modules, within a project folder. However, I noticed that it only loops through open modules of the folder. If I start opening up, the results are unpredictable, it seems that the dxl is processing modules backwards, with the most recent one being first.

Is there a way to process the modules in order and without opening them? I have this simple control structure:

for m in f do {
// loop through each module in the folder
for obj in m do {
// process the object text on each object
}

}
mirlo - Fri Mar 05 15:14:04 EST 2010

Re: Dxl looping only through open modules?
SystemAdmin - Sat Mar 06 11:16:51 EST 2010

You have to go through the items in the project to access non-open modules. Also if you really want to modify Object Text for objects, you have to open the modules for edit.

For an example look at

https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14289511&#14289511

Re: Dxl looping only through open modules?
llandale - Sun Mar 07 14:54:40 EST 2010

Huh?

for mod in database do
for mod in proj do

These loop through open modules in the database or the specified Project. I don't know what the 'order' is.

I suspect you care only about open VISIBLE modules, not link modules or their residual open link partners. Try
if (!isVisible(mod)) continue

I suspect you may be modifying these modules, in which case the module must be open edit exclusive:
if (!isEdit(mod)) continue

Lets process all open modules in alpha order, those that are open Edit and visible:

Module mod
string NameMod
Skip skpMods = createSting()  // KEY: 'string' NameMod(base); DATA: 'Module' handle
print "Module found order..."
for mod in database do
{  NameMod = name(mod)   // the 'fullName(mod)' would include the path info
   print "\t" NameMod
   put(skpMods, NameMod, mod)  // Put the name as Key.
}  // end for open modules in the Database
print "\n"
 
        // loop through Key-sorted Skip, which is Alpha since the key is the 'name' -
print "Module from Skip order..."
for mod in skpMods do             // Skips loop through the DATA -
{  NameMod = (string key skpMods) // Retrieve the KEY (name) associated with this DATA mod
   print "\t" NameMod
   if (!isVisible(mod)) continue
   if (!isEdit(mod)     continue
   ProcessOpenEditModule(mod)  // << you write this function
}  // end for open modules in the Skip
print "\n"
delete(skpMods)

 

 

  • Louie

 

 

Re: Dxl looping only through open modules?
SystemAdmin - Fri Mar 19 05:17:10 EDT 2010

llandale - Sun Mar 07 14:54:40 EST 2010

Huh?

for mod in database do
for mod in proj do

These loop through open modules in the database or the specified Project. I don't know what the 'order' is.

I suspect you care only about open VISIBLE modules, not link modules or their residual open link partners. Try
if (!isVisible(mod)) continue

I suspect you may be modifying these modules, in which case the module must be open edit exclusive:
if (!isEdit(mod)) continue

Lets process all open modules in alpha order, those that are open Edit and visible:

Module mod
string NameMod
Skip skpMods = createSting()  // KEY: 'string' NameMod(base); DATA: 'Module' handle
print "Module found order..."
for mod in database do
{  NameMod = name(mod)   // the 'fullName(mod)' would include the path info
   print "\t" NameMod
   put(skpMods, NameMod, mod)  // Put the name as Key.
}  // end for open modules in the Database
print "\n"
 
        // loop through Key-sorted Skip, which is Alpha since the key is the 'name' -
print "Module from Skip order..."
for mod in skpMods do             // Skips loop through the DATA -
{  NameMod = (string key skpMods) // Retrieve the KEY (name) associated with this DATA mod
   print "\t" NameMod
   if (!isVisible(mod)) continue
   if (!isEdit(mod)     continue
   ProcessOpenEditModule(mod)  // << you write this function
}  // end for open modules in the Skip
print "\n"
delete(skpMods)

 

 

  • Louie

 

 

Might want to put in an if there to make sure you only get formal modules :)

if (type mod == "Formal") then put(skpMods, NameMod, mod)  // Put only formal modules in the list, the name as Key.

 


/Kristian

 

Re: Dxl looping only through open modules?
SystemAdmin - Mon Mar 22 10:53:36 EDT 2010

SystemAdmin - Sat Mar 06 11:16:51 EST 2010
You have to go through the items in the project to access non-open modules. Also if you really want to modify Object Text for objects, you have to open the modules for edit.

For an example look at

https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14289511&#14289511

I second Pekka. Looping through items is the way to go if you're looking to hit all modules.

Re: Dxl looping only through open modules?
mirlo - Mon Mar 22 16:47:14 EDT 2010

SystemAdmin - Mon Mar 22 10:53:36 EDT 2010
I second Pekka. Looping through items is the way to go if you're looking to hit all modules.

Thanks to everyone, the suggestions worked perfectly.