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: Checking if Module exists with specified string name
Topic Summary:
Created On: 23-Oct-2007 21:03
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.
 23-Oct-2007 21:03
User is offline View Users Profile Print this message


Brian Rohler

Posts: 26
Joined: 20-Jun-2007

I need to see if a Module already exists. If it doesn't, then I'll create it. If it does, then I'll use the one that already exists. The problem is that I don't have the handle for the Module, only the string name. I've seen the use of the following code in some kitchen scripts: if(!exists Module_ modNameString).... but, this doesn't seem to work. Anybody have any ideas? thanks!
Report this to a Moderator Report this to a Moderator
 24-Oct-2007 07:49
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

Hi Brian,

the answer to your question is so simple, that you did not saw the wood for the trees

if (!module modNameString) { ....
should do what you need.

Alternatively you may use
if (!exists module modNameString) { ...

To see if the module is already open you may use
if (open module modNameString) { ...

Greetings
Reik

-------------------------
Evosoft GmbH
for Siemens Industry Sector


Berlin, Germany
Report this to a Moderator Report this to a Moderator
 24-Oct-2007 15:28
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Schroeder is right. Except his 3rd example will cause DXL run-time errors if the module doesn't exist. I have a personal distaste for nested calls to overloaded functions, so I'd be tempted to make it two lines: ModName_ mn = module(modNameString); if (!module mn)...

As for typing a reference:

The construct 'Module_ modNameString' should mean 'use the version of modNameString that's of type Module_'. That may make some sense when modNameString is an overloaded function that can return more than one type of variable, it doesn't make sense when modNameString is a variable and therefore has only one type. Also, I don't see a valid type of 'Module_' so that isn't going to work anyway.

A common use is 'current', which is a function: 'for obj in (Module current) do'.

Besides selecting between overloaded functions, typing can be used when retrieving the 'key' from a skip list: Value = (string key skp).

I may not recall this exactly correctly, but we recently experienced some problems in Layouts that rely on auto-declare: 'o = target(lnk)'. Note that the 'target(lnk)' function is overloaded, and can be 'Object' or 'string' or 'ModName_'. In v7 that phrase defaulted to 'Object' (it appears Object target(lnk) was defined internally before 'ModName_ target(lnk)', but in v8 it defaulted to ModName_. Thus, when we migrated these silly auto-declare layouts didn't work. We could have resolved it by typing 'o': 'Object o = target(lnk)'; or could have typed target: 'o = Object target(lnk)'. Of course, turning off the rediculous auto-declare would have solved the problem but I digress...

- 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.