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: problem with current module
Topic Summary: current module not set if module already open
Created On: 18-Jun-2007 11:46
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.
Answer This question was answered by Jim Backus, on Monday, June 18, 2007 5:53 PM

Answer:
Tony,

Thanks for the reply. I knew about the difference between ModName_ and Module reference, but was expecting DOORS to keep track of 'current', which on reflection was unreasonable.

Presumably 'current' applies up the hierarchy in the sense that if an object is current in a module, the module is current as is the folder and project that contains it. Working the other way, DOORS cannot guess which module is current when several could be open.

I hadn't realised that read(modname, bool) could be used to make the named module current without changing the edit mode.

Thanks again

Jim
 18-Jun-2007 11:46
User is offline View Users Profile Print this message


Jim Backus

Posts: 21
Joined: 27-Apr-2006

I've recently done the DOORS DXL course but still struggling with some issues.

I've written a script to report on the attributes and types used in a module which works as expected apart from a few lines at the start that are supposed to check if a module is open and conditionally open it. The problem is that if the module is already open, 'current' is not set.

I'm trying to run the code from the DXL interaction window at the database level. It may work OK if I run from the module's DXL interaction window.

Code attached

-------------------------
Jim Backus<BR>Ultra Electronics, Controls
Report this to a Moderator Report this to a Moderator
 18-Jun-2007 15:27
User is offline View Users Profile Print this message


Tony Goodman

Posts: 1098
Joined: 12-Sep-2002

You are confusing the Module type handle with the ModName_ handle.

Any way, you only care if the module is open when you are tidying up by closing them.
Use read(modname, false) to open the module which gives you a good handle on the module whether it was open or not.

See the attached.

-------------------------
Tony Goodman
http://www.smartdxl.com
Report this to a Moderator Report this to a Moderator
 18-Jun-2007 17:21
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

[1] Attached is my fIsOpen function. I routinely use this in scripts that open lots of modules figuring the script will close the module unless its already open. I use the overloaded bool function (2nd function attached).

for NameModFull in the folder and below
{ IsOpen = fIsOpen(NameModFull, false)
mod = read(NameModFull, false)
deal with mod
if (!IsOpen) close(mod, false)
}

[2] Your original script makes use of 'current' module. That makes sense only when running from an open module:
Module mCurr = current
if (null mCurr) {infoBox("Run from open module"); halt}

Since your script is intended to run from the explorer, there is no reason to consider the notion of a current module.

Note: in Versions past, opening a module changed the 'current' module. That creates havok with scripts that use functions that presume current module; most attribute def and type functions presume current module. To resolve that, I routinely insert the following above such commands:
current = mCurr
This makes sure I know which module is current.

I don't know if the new versions of DOORS changes the current module when you open one; but my scripts are bullet proof to that now.

- Louie
Report this to a Moderator Report this to a Moderator
 18-Jun-2007 17:53
User is offline View Users Profile Print this message


Jim Backus

Posts: 21
Joined: 27-Apr-2006

Answer Answer
Tony,

Thanks for the reply. I knew about the difference between ModName_ and Module reference, but was expecting DOORS to keep track of 'current', which on reflection was unreasonable.

Presumably 'current' applies up the hierarchy in the sense that if an object is current in a module, the module is current as is the folder and project that contains it. Working the other way, DOORS cannot guess which module is current when several could be open.

I hadn't realised that read(modname, bool) could be used to make the named module current without changing the edit mode.

Thanks again

Jim

-------------------------
Jim Backus<BR>Ultra Electronics, Controls
Report this to a Moderator Report this to a Moderator
 18-Jun-2007 19:30
User is offline View Users Profile Print this message


David Pechacek

Posts: 674
Joined: 5-Dec-2006

quote:

I don't know if the new versions of DOORS changes the current module when you open one; but my scripts are bullet proof to that now.


Yes it does. When you open a module in a DXL script, the current module is changed to that newly opened module. So if you need the current module to be the module you are running the script from, you must reassign it to be the current module.

If you didn't get a handle on the module you're running the script from before opening another module, then you won't be able to without code similar to louie's.

-------------------------
David Pechacek
AAI Services Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com
Report this to a Moderator Report this to a Moderator
 18-Jun-2007 22:59
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

... maybe the old DOORS would change current even when you open a module that was already open, but the new DOORS only changes current when the module wasn't already open.....

Anyway, for scripts that work on the current module, I see no way around not having something like this at the top:
Module mCurr = current
if (null mCurr) {infoBox("Run from open module"); halt}

That makes sure the script is running from an open module, and keeps a handle on that module which surely will be used elsewhere.

- Louie
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 2 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 2 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.