Getting a Handle on a Module

Hi all. I'm having an issue that I'd like some help with. I am not a Software Engineer, so I'm sur ethat this is a simple issue for most of you, but the solution is escaping me.

I am trying to loop through a project and identify Formal Modules. Then I want to pull some module information from the Formal Modules. Here is the loop portion of my code:
 

for item in current Project do {
    iType = type(item)
        if (iType == "Formal") {
 
        }
}

 


My issue is that once an item is identified as a Formal Module, how do I get a handle on it to pull information from the Module Attributes (in the form (Module m)."Description")?

Thanks,
Matt

 


MHerald - Thu Aug 27 07:48:08 EDT 2009

Re: Getting a Handle on a Module
SystemAdmin - Thu Aug 27 08:06:00 EDT 2009

Open the module, either read-only, shareable or for edit. In the example below I open the module as read-only by getting the fullName of the item and then print out the module name and description.
 

Item item = (Item null)
string iType = ""
Module m = null
for item in current Project do 
    {
    iType = type(item)
        if (iType == "Formal") 
            {
              m = read(fullName(item), false)
              print name(m) ": " m."Description" "\n"
              close m
            }
     }
}

 


If you are using DOORS version 8.2 or later is also possible to get module description value and other module attribute values through ModuleProperties without opening the modules. Check this in DXL Help.

 

Re: Getting a Handle on a Module
MHerald - Thu Aug 27 08:49:22 EDT 2009

Thanks for the help. I had a feeling that the only way to get a handle on it was to open the module, but I wanted to check with someone else, first.

Thanks again.

Re: Getting a Handle on a Module
Bosch - Thu Jun 23 07:17:14 EDT 2011

SystemAdmin - Thu Aug 27 08:06:00 EDT 2009

Open the module, either read-only, shareable or for edit. In the example below I open the module as read-only by getting the fullName of the item and then print out the module name and description.
 

Item item = (Item null)
string iType = ""
Module m = null
for item in current Project do 
    {
    iType = type(item)
        if (iType == "Formal") 
            {
              m = read(fullName(item), false)
              print name(m) ": " m."Description" "\n"
              close m
            }
     }
}

 


If you are using DOORS version 8.2 or later is also possible to get module description value and other module attribute values through ModuleProperties without opening the modules. Check this in DXL Help.

 

Hello,

I am looking for a dxl script where it will generate a report for all the modules the attribute "last modified by" and "last modified on" data with the module path.

Kindly do the needfull.

kindly let me know if this possible.

Thank you!

Regards,
Shruthi

Re: Getting a Handle on a Module
Mathias Mamsch - Thu Jun 23 07:38:54 EDT 2011

MHerald - Thu Aug 27 08:49:22 EDT 2009
Thanks for the help. I had a feeling that the only way to get a handle on it was to open the module, but I wanted to check with someone else, first.

Thanks again.

You do not need to open the module if you only want to query module attributes. There is a fuction for querying the module properties of a module:
 

string readProperty(ModuleVersion mv, string sName) {
     // Unfortunately, the DXL-perm getProperties() has a momory leak in DOORS 8.2 (is fixed in DOORS 8.3), when a closed module is opened. 
      // In DOORS 8.2 it is therefore better to open the module and read the module attribute directly. 
      string errString = getProperties (mv, modProp) 
 
      string attrName
    
      if (null errString) {                   
          for attrName in modProp do {
              if (attrName == sName) 
                  return (modProp.sName) ""
          }
      }
    
     return ""
   }
 
   ModName_ mn = module "/Playground/MyModule"
 
   // lets read from the current version
   print readProperty(moduleVersion mn, "Created On")  "\n"
   print readProperty(moduleVersion mn, "Last Modified On") "\n" 
   print readProperty(moduleVersion mn, "Name") "\n"

 


Hope this helps, regards, Mathias

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Re: Getting a Handle on a Module
Bosch - Thu Jun 23 08:07:46 EDT 2011

SystemAdmin - Thu Aug 27 08:06:00 EDT 2009

Open the module, either read-only, shareable or for edit. In the example below I open the module as read-only by getting the fullName of the item and then print out the module name and description.
 

Item item = (Item null)
string iType = ""
Module m = null
for item in current Project do 
    {
    iType = type(item)
        if (iType == "Formal") 
            {
              m = read(fullName(item), false)
              print name(m) ": " m."Description" "\n"
              close m
            }
     }
}

 


If you are using DOORS version 8.2 or later is also possible to get module description value and other module attribute values through ModuleProperties without opening the modules. Check this in DXL Help.

 

Hello,

I am looking for a dxl script where it will generate a report for all the modules the attribute "last modified by" and "last modified on" data based on only the project selected in the GUI with the module path.

Kindly do the needfull.

kindly let me know if this possible.

Thank you!

Regards,
Shruthi

Re: Getting a Handle on a Module
David_G_Bond - Thu Jun 23 10:06:09 EDT 2011

SystemAdmin - Thu Aug 27 08:06:00 EDT 2009

Open the module, either read-only, shareable or for edit. In the example below I open the module as read-only by getting the fullName of the item and then print out the module name and description.
 

Item item = (Item null)
string iType = ""
Module m = null
for item in current Project do 
    {
    iType = type(item)
        if (iType == "Formal") 
            {
              m = read(fullName(item), false)
              print name(m) ": " m."Description" "\n"
              close m
            }
     }
}

 


If you are using DOORS version 8.2 or later is also possible to get module description value and other module attribute values through ModuleProperties without opening the modules. Check this in DXL Help.

 

I've run into cases in DOORS where if an open module is opened again, extra memory is used and in many cases memory is precious when dealing with DOORS. I recommend checking to see if a module is already open before re-opening it:
{code}
if (open(module(fullName(item))))
{

Re: Getting a Handle on a Module
David_G_Bond - Thu Jun 23 10:15:40 EDT 2011

David_G_Bond - Thu Jun 23 10:06:09 EDT 2011
I've run into cases in DOORS where if an open module is opened again, extra memory is used and in many cases memory is precious when dealing with DOORS. I recommend checking to see if a module is already open before re-opening it:
{code}
if (open(module(fullName(item))))
{

Okay, the darn interface zigged when I wanted it to zag and it didn't let me edit it. What I was saying is that I always check to see if a module is already open before I open it. I've had memory problems in some cases where a lot of links are followed if I blindly open the modules. I suggest something like the following:

Item it = (Item null)
string iType = ""
Module m = null
string sItemName
for it in current Project do 
{
    iType = type(it)
    if (iType == "Formal") 
    {
        sItemName = fullName(it)
        if (open(module(sItemName))) m = module(it)
        else m = read(sItemName, false)
        print name(m) ": " m."Description" "\n"
        close m
    }
}

Re: Getting a Handle on a Module
Mathias Mamsch - Thu Jun 23 13:02:14 EDT 2011

Mathias Mamsch - Thu Jun 23 07:38:54 EDT 2011

You do not need to open the module if you only want to query module attributes. There is a fuction for querying the module properties of a module:
 

string readProperty(ModuleVersion mv, string sName) {
     // Unfortunately, the DXL-perm getProperties() has a momory leak in DOORS 8.2 (is fixed in DOORS 8.3), when a closed module is opened. 
      // In DOORS 8.2 it is therefore better to open the module and read the module attribute directly. 
      string errString = getProperties (mv, modProp) 
 
      string attrName
    
      if (null errString) {                   
          for attrName in modProp do {
              if (attrName == sName) 
                  return (modProp.sName) ""
          }
      }
    
     return ""
   }
 
   ModName_ mn = module "/Playground/MyModule"
 
   // lets read from the current version
   print readProperty(moduleVersion mn, "Created On")  "\n"
   print readProperty(moduleVersion mn, "Last Modified On") "\n" 
   print readProperty(moduleVersion mn, "Name") "\n"

 


Hope this helps, regards, Mathias

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Whoops, that code was incomplete, Mathias
 

// declare ModuleProperties (darn who activated my auto declare ...) 
    ModuleProperties modProp

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: Getting a Handle on a Module
Bosch - Thu Aug 18 10:10:25 EDT 2011

Mathias Mamsch - Thu Jun 23 07:38:54 EDT 2011

You do not need to open the module if you only want to query module attributes. There is a fuction for querying the module properties of a module:
 

string readProperty(ModuleVersion mv, string sName) {
     // Unfortunately, the DXL-perm getProperties() has a momory leak in DOORS 8.2 (is fixed in DOORS 8.3), when a closed module is opened. 
      // In DOORS 8.2 it is therefore better to open the module and read the module attribute directly. 
      string errString = getProperties (mv, modProp) 
 
      string attrName
    
      if (null errString) {                   
          for attrName in modProp do {
              if (attrName == sName) 
                  return (modProp.sName) ""
          }
      }
    
     return ""
   }
 
   ModName_ mn = module "/Playground/MyModule"
 
   // lets read from the current version
   print readProperty(moduleVersion mn, "Created On")  "\n"
   print readProperty(moduleVersion mn, "Last Modified On") "\n" 
   print readProperty(moduleVersion mn, "Name") "\n"

 


Hope this helps, regards, Mathias

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Hello Mathias,

I have huge list of modules in a database like almost around 2000 modules, so i want to run a script were it will display the module names and module attributes "Last modified by" and "Last modified on" for the current project.

In the current project there are huge list of sub projects so it has to run through all the items inside that and print only the module name and module attributes as mentioned above.

i have tried the below script but since the database is containing a huge data so the doors is crashing.

Kindly help me out is there any better way were i am able to run the script at a stretch to display the module names and the module attributes.

//Stream str_Groups = write("C:/temp/doorsGroupList.tsv")
//str_Groups << "ModuleName" << "\t" << "LastModifiedBy" "\t" << "LastModifedOn" << "\n"
pragma runLim,0
Item it = (Item null)
string iType = ""
Module m = null
string sItemName
print "ModuleName" "\t" "LastModifiedBy" "\t" "LastModifedOn" "\n"
int count = 0;
for it in current Project do
{
iType = type(it)
if (iType == "Formal")
{
m = read(fullName(it), false)
if(!null m)
{
print fullName(m) "\t" m."Last Modified By" "\t" m."Last Modified On" "\n"
//str_Groups << fullName(m) << "\t" << m."Last Modified By" << "\t" << m."Last Modified On" "\n"
close m
}
}
}

Re: Getting a Handle on a Module
llandale - Fri Aug 19 15:13:50 EDT 2011

Bosch - Thu Aug 18 10:10:25 EDT 2011
Hello Mathias,

I have huge list of modules in a database like almost around 2000 modules, so i want to run a script were it will display the module names and module attributes "Last modified by" and "Last modified on" for the current project.

In the current project there are huge list of sub projects so it has to run through all the items inside that and print only the module name and module attributes as mentioned above.

i have tried the below script but since the database is containing a huge data so the doors is crashing.

Kindly help me out is there any better way were i am able to run the script at a stretch to display the module names and the module attributes.

//Stream str_Groups = write("C:/temp/doorsGroupList.tsv")
//str_Groups << "ModuleName" << "\t" << "LastModifiedBy" "\t" << "LastModifedOn" << "\n"
pragma runLim,0
Item it = (Item null)
string iType = ""
Module m = null
string sItemName
print "ModuleName" "\t" "LastModifiedBy" "\t" "LastModifedOn" "\n"
int count = 0;
for it in current Project do
{
iType = type(it)
if (iType == "Formal")
{
m = read(fullName(it), false)
if(!null m)
{
print fullName(m) "\t" m."Last Modified By" "\t" m."Last Modified On" "\n"
//str_Groups << fullName(m) << "\t" << m."Last Modified By" << "\t" << m."Last Modified On" "\n"
close m
}
}
}

Go with Mathias' method of querying ModuleProperties which do not require you to open the module.

Although clearly a minority opinion, I think the following method of browsing for modules is better than the standard "for item in Project do" loop.

void DealWithModule(string NameModFull)
{  // do whatever I want
}
 
void DealWithFolder(Folder fld)
{    // RECURSIVE ENABLED.  Process folder and sub-folders and sub-projects
  if (null fld) return()
  Skip skpItems = create()
  Item itm
  Folder fldNew
 
  for itm in fld do
  {  put(skpItems, name(itm), itm)  // sorts in Alpha order
  }
  for itm in skpItems do
  {  if (type(itm) != "Formal") continue
     DealWithModule(fullName(itm))
  }
  for itm in skpItems do
  {  if (type(itm) != "Folder" and type(itm) != "Project") continue
     fldNew = folder(itm)
     DealWithFolder(fldNew)  // ** RECURSION **
  }
  delete(skpItems)
}
DealWithFolder(current Folder)


The method gets them in natural Hierarchy-Alpha order that you see them in the GUI. You could add "bool DoSubFolders, DoSubProjects" to decide whether to recurse them or not.

I notice DOORS slows down drastically the more print statements you have. Instead of printing, define a global buffer and put the results therein, then print the buffer at the end.
Buffer g_bufResults = create()
g_bufResults = "ModuleName\tLastModifiedBy\tLastModifedOn\n"
...
... g_bufResults += fullName(m) "\t" m."Last Modified By" "\t" m."Last Modified On" "\n"
...
print tempStringOf(g_bufResults)
delete(g_bufResults)

 

 

  • Louie