Weird behaviour of "for srcModName in o"

I'm using the following code to count the number of objects that don't have a link. It seems to work, and the print instruction prints "Test cases" but when I replace "*" with "Test cases", the for statement doesn't find any matches. What gives? Secondly the DOORS 8.2 DXL Reference Manual states that srcModName uses the link module name; however, it seems to take the source module name instead. Is this an error in the manual? Lastly, is there a better way to do this? Thanks, Ken.
 

for o in m do {
    count++
        count_notests++ // assume object doesn't have an in-link
        increment = false
        for srcModName in o <- "*" do { 
        increment = true
        print srcModName "\n"
        }
        if (increment) count_notests--  //object does have an in-link
        }
}

mcnairk - Mon Sep 19 11:52:06 EDT 2011

Re: Weird behaviour of "for srcModName in o"
llandale - Mon Sep 19 16:24:35 EDT 2011

>>1 The srcModName loop is useless as it returns the base name of source module, and if that module is in some other folder you may not be able to find it. Also, it is the SOURCE module name.
>>2 The link loop is asking for a LinkModule name, where "*" means "any"
>>3 You may not see incoming "Link"s, but you can see incoming "LinkRef"s

Try the for all source references, using ModName_ srcModRef. Then you can print the fullName of the source along with the fullName of the LinkModule.

Scribbling, may look like this:

ModName_ mmSource
Module  mLMod
LinkRef lr
 
for lr in o<" do
{  mnSource = source(lr)
   mLMod    = module(lr)
   print "\thas link from: " (fullName(mnSource)) "\t  in LMod  " (fullName(mLMod)) "\n"
}

 

  • Louie

 

Re: Weird behaviour of "for srcModName in o"
mcnairk - Tue Sep 20 10:25:11 EDT 2011

llandale - Mon Sep 19 16:24:35 EDT 2011

>>1 The srcModName loop is useless as it returns the base name of source module, and if that module is in some other folder you may not be able to find it. Also, it is the SOURCE module name.
>>2 The link loop is asking for a LinkModule name, where "*" means "any"
>>3 You may not see incoming "Link"s, but you can see incoming "LinkRef"s

Try the for all source references, using ModName_ srcModRef. Then you can print the fullName of the source along with the fullName of the LinkModule.

Scribbling, may look like this:

ModName_ mmSource
Module  mLMod
LinkRef lr
 
for lr in o<" do
{  mnSource = source(lr)
   mLMod    = module(lr)
   print "\thas link from: " (fullName(mnSource)) "\t  in LMod  " (fullName(mLMod)) "\n"
}

 

  • Louie

 

Works dandy after fixing a couple of typos:
 

ModName_ mnSource
Module  mLMod
LinkRef lr
for lr in o <- "*" do
{  mnSource = source(lr)
   mLMod    = module(lr)
   print "\thas link from: " (fullName(mnSource)) "\t  in mLMod  " (fullName(mLMod)) "\n"
}

 


Many thanks!

Ken.

 

Re: Weird behaviour of "for srcModName in o"
llandale - Tue Sep 20 10:56:06 EDT 2011

mcnairk - Tue Sep 20 10:25:11 EDT 2011

Works dandy after fixing a couple of typos:
 

ModName_ mnSource
Module  mLMod
LinkRef lr
for lr in o <- "*" do
{  mnSource = source(lr)
   mLMod    = module(lr)
   print "\thas link from: " (fullName(mnSource)) "\t  in mLMod  " (fullName(mLMod)) "\n"
}

 


Many thanks!

Ken.

 

Forgot to mention that in this loop you can open the source module invisibly, which gives you access to the "Link" and also the source "Object". Then after this loop you can use the "for lnk in o<-"*" loop.

The code to 'read' a module that is already open doesn't take much time, for me 100,000 extra 'read' commands for a very large module took only 4 seconds.