![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
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 |
![]() |
![]()
|
![]() |
|
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!
|
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.