DXL: Using a regular expression at the end of a link

Hey,

I'm having some problems with a bit of code i'm trying to write. I want to count the number of in-links of each object when the source and target objects are in the same module and also has a specific regular expression in one of the source object attributes.

***
Module A
IE PUID Object Text Link Direction
CAPA Text 1 <--

FUNC Text 2 -->
***
The code below just seems to count the number of objects that has "FUNC" in the attribute of the module and not the attribute at the other end of the link:

\\There is other code above this that reads the module and defines 'obj' and 'counter'.

Link lnk
for lnk in obj <- "*" do
{
Regexp srcPuid = regexp "FUNC"
string reqSrcAttr = obj."IE PUID"
if (srcPuid reqSrcAttr)
{
counter++
}
}

Any suggestions?

Thanks,
John
jmcgown - Wed Dec 16 06:49:07 EST 2009

Re: DXL: Using a regular expression at the end of a link
llandale - Wed Dec 16 10:52:01 EST 2009

You need to get a handle on the object at the other end of the link:
Object oOther = source(lnk); if (null oOther) continue

The 'regexp' function is EXTREMELY inefficient. Certainly move it out of the loop. In fact, searching for normal stuff like that you should just write a search utility, byte-by-byte searching in a buffer. Its more complicated, but much faster and doesn't tie up string table space, eventually slowing down DOORS even after the script ends.

  • Louie

Re: DXL: Using a regular expression at the end of a link
jmcgown - Wed Dec 16 12:00:11 EST 2009

llandale - Wed Dec 16 10:52:01 EST 2009
You need to get a handle on the object at the other end of the link:
Object oOther = source(lnk); if (null oOther) continue

The 'regexp' function is EXTREMELY inefficient. Certainly move it out of the loop. In fact, searching for normal stuff like that you should just write a search utility, byte-by-byte searching in a buffer. Its more complicated, but much faster and doesn't tie up string table space, eventually slowing down DOORS even after the script ends.

  • Louie

Hi Louie,

Thanks for that, it works a treat!

is a 'matches' function as inefficient as the 'regexp'?
Thanks,
John