Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: how to test for a module attribute without crashing DXL
Topic Summary: Module attributes
Created On: 13-Dec-2005 23:04
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 13-Dec-2005 23:04
User is offline View Users Profile Print this message


Janet Ma

Posts: 115
Joined: 12-Sep-2002

I am writing a script to get the information out of project modules by using a for loop through a project.

One of the attributes is a module attribute which I am testing whether or not it exists

if (exists attribute "allocation"){
string s = m."allocation"""
}

the dxl halts because the module attribute doesn't exist, is there a better way to test for a module attribute?

I also tried:

AttrDef ad = find(m, "allocation")
if (!null ad) string s = m."allocation"""

but it still crashes.
Report this to a Moderator Report this to a Moderator
 14-Dec-2005 00:30
User is offline View Users Profile Print this message


Shawn Stepper

Posts: 96
Joined: 6-Aug-2004

Use the AttrDef properties, like this:

AttrDef ad = find(m, "allocation")

if (!null ad && ad.module) {
string s = m."allocation" ""
}



-------------------------
Shawn Stepper
shawn.e.stepper@wellsfargo.com
Report this to a Moderator Report this to a Moderator
 14-Dec-2005 22:44
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Shawn's solution is the best one. It insure that the attribute is in fact a module level attribute, and not just a text attribute (such as Object Text).

The original code had the failing that the "exists" command works only the the "current" module, which is usually but not always the last module opened. Before such commands, explicitely set the current module "current = m".

You can trap DXL crashes around lines of code like this:
noError()
s = m."allocation"
string ErrMess = lastError()
if (!null ErrMess) print ErrMess; s is no good.
else s is good.

- Louie
Report this to a Moderator Report this to a Moderator
 5-Jan-2006 19:13
User is offline View Users Profile Print this message


Janet Ma

Posts: 115
Joined: 12-Sep-2002

Thanks Shawn, Louie, I'll try both of your solutions.
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.