How to obtain the Module prefix for a target module?

Hi,
Does anyone know if there is some way to obtain the module prefix from a link target module? I have the module reference, but doing something like TargetMod."prefix" doesn't work. I'm trying to create a full object ID (prefix + absolute number) for the linked object.

Thanks in advance!
SteveK01 - Tue Nov 03 21:02:15 EST 2009

Re: How to obtain the Module prefix for a target module?
SystemAdmin - Wed Nov 04 01:50:01 EST 2009

Function identifier(Object) will return you the Object Identifier (Prefix + Absolute Number).

doing something like TargetMod."prefix" doesn't work.

Would TargetMod."Prefix" work? DOORS is case sensitive.

Cheers, Pekka

Re: How to obtain the Module prefix for a target module?
ePiallat - Wed Nov 04 02:59:40 EST 2009

Hi,

I'm afraid DOORS is not case sensitive about attributes name. Targetmod."Prefix" is equivalent to Targetmod."pREfiX".

However, I suspect you made the confusion between an attribute reference and an attribute value. To recover the value of an attribute, most of the time you need to translate the reference into a value.

To be clearer:

print TargetMod."prefix" // this will fail: try to print an Attr_
print TargetMod."prefix" "" // this will work: Attr_ is translated into a plain text string before printing
print richText TargetMod."prefix" // this will work: Attr_ is translated into a rich text string before printing

 


Of course, the third form is useless for a prefix.

It's the same for a test:

 

 

if (TargetMod."prefix" "" == "") { // correct syntax to test an empty prefix

 

Re: How to obtain the Module prefix for a target module?
SystemAdmin - Wed Nov 04 03:21:28 EST 2009

ePiallat - Wed Nov 04 02:59:40 EST 2009

Hi,

I'm afraid DOORS is not case sensitive about attributes name. Targetmod."Prefix" is equivalent to Targetmod."pREfiX".

However, I suspect you made the confusion between an attribute reference and an attribute value. To recover the value of an attribute, most of the time you need to translate the reference into a value.

To be clearer:

print TargetMod."prefix" // this will fail: try to print an Attr_
print TargetMod."prefix" "" // this will work: Attr_ is translated into a plain text string before printing
print richText TargetMod."prefix" // this will work: Attr_ is translated into a rich text string before printing

 


Of course, the third form is useless for a prefix.

It's the same for a test:

 

 

if (TargetMod."prefix" "" == "") { // correct syntax to test an empty prefix

 

My mistake, thank you for correcting it.

Re: How to obtain the Module prefix for a target module?
Illo_993 - Wed Nov 04 03:43:27 EST 2009

Hi @all,

just a hint related to your code examples:
I assume that the referenced variable "TargetMod" is of type Module. The value must be a reference to an opened module.

Starting with DOORS v8.2 there's a much faster way to access module attributes without the need to open it. The only thing you need is a reference to a module of type ModName_:

// ### begin code ######################################
ModName_ modRef = <initialized>
string attr_Val = ""

// Prepare the call to the fnc 'getProperties'
ModuleVersion mod_version = moduleVersion( modRef )
ModuleProperties mod_properties = null

string errmsg = getProperties( mod_version, mod_properties )
if (!null errmsg) <do some error reporting/handling>

// Try to get the desired attribute; catch and report any error if not found
if (find( mod_properties, attr_Name ) != null)
{
attr_Val = unicodeString( mod_properties.attr_Name )
}
else
{
<do some error reporting/handling>
}
// ### end code ######################################
Cheers,
Illo

Re: How to obtain the Module prefix for a target module?
SteveK01 - Wed Nov 04 18:43:48 EST 2009

Hi everyone, thanks for the responses! I guess I should have been a little more descriptive.
To ePiallat: Yes, I am aware of the force to string. That didn't work. I get an oncorrectly concantanated tokens error that way. The original error is "incorrect arguments for (.)"

Oh, and the "prefix" was a typo here, I actually am using "Prefix", but it doesn't seem to matter...

To Illo: The variable TargetMod is of type ModName_ (a module reference). I'm working in DOORS v9.2.
The code roughly looks like:

Link OutLink
ModName_ targetMod
...
for OutLink in O->"*" do
{
targetMod = target OutLink
read(fullName(targetMod), false)
TargetObj = target(OutLink)
targAbsNo = targetAbsNo (OutLink)
string TargModPref = targetMod."Prefix" ""
Process_log += TargModPref targAbsNo "\t" TargetObj."Object Text" "\n"
}

But... using Function identifier(Object) works great!! Thanks Pekka! so now the code looks like:
read(fullName(targetMod), false)
TargetObj = target(OutLink)
targAbsNo = targetAbsNo (OutLink)
string TargModPref = identifier(TargetObj)

Process_log += TargModPref targAbsNo "\t" TargetObj."Object Text" "\n"
and I'm a happy camper. Thanks everyone, this was a simple solution to something that was killing me.

Re: How to obtain the Module prefix for a target module?
SteveK01 - Wed Nov 04 19:15:13 EST 2009

Something is wrong with my repost - disallowed content...trying again.

My previous entry was poor (I got excited that it worked!)

The corrected code is:
...
targetMod = target OutLink
read(fullName(targetMod), false)
TargetObj = target(OutLink)
string TargModPref = identifier(TargetObj)
Process_log += TargModPref "\t" TargetObj."Object Text" "\n"
...
Sorry for the double post. Got excited that it worked.
-Steve

Re: How to obtain the Module prefix for a target module?
ePiallat - Thu Nov 05 03:32:15 EST 2009

SteveK01 - Wed Nov 04 18:43:48 EST 2009
Hi everyone, thanks for the responses! I guess I should have been a little more descriptive.
To ePiallat: Yes, I am aware of the force to string. That didn't work. I get an oncorrectly concantanated tokens error that way. The original error is "incorrect arguments for (.)"

Oh, and the "prefix" was a typo here, I actually am using "Prefix", but it doesn't seem to matter...

To Illo: The variable TargetMod is of type ModName_ (a module reference). I'm working in DOORS v9.2.
The code roughly looks like:

Link OutLink
ModName_ targetMod
...
for OutLink in O->"*" do
{
targetMod = target OutLink
read(fullName(targetMod), false)
TargetObj = target(OutLink)
targAbsNo = targetAbsNo (OutLink)
string TargModPref = targetMod."Prefix" ""
Process_log += TargModPref targAbsNo "\t" TargetObj."Object Text" "\n"
}

But... using Function identifier(Object) works great!! Thanks Pekka! so now the code looks like:
read(fullName(targetMod), false)
TargetObj = target(OutLink)
targAbsNo = targetAbsNo (OutLink)
string TargModPref = identifier(TargetObj)

Process_log += TargModPref targAbsNo "\t" TargetObj."Object Text" "\n"
and I'm a happy camper. Thanks everyone, this was a simple solution to something that was killing me.

Great !
For further notice, the problem was that "targetMod" is not a Module, but a ModName_.

If you need some module property from an open module some days, try to write this instead:

Link OutLink
ModName_ targetModName
Module targetMod
...
for OutLink in O->"*" do
{
targetModName = target OutLink
targetMod = read(fullName(targetModName), false)
TargetObj = target(OutLink)
targAbsNo = targetAbsNo (OutLink)
string TargModPref = targetMod."Prefix" ""
Process_log += TargModPref targAbsNo "\t" TargetObj."Object Text" "\n"
}