![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: current [module] Topic Summary: current module function documentation Created On: 11-Mar-2008 21:13 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
In the DXL Reference Manual for DOORS 8.1, page 245, they have a section
current [module]: ------------------------------------------------------------------------------------------- Declaration Module current() Operation Returns a reference to the current module. In some contexts current could be ambiguous, in which case it should be followed by Module in a cast. Example print (current Module)."Description" "\n" ------------------------------------------------------------------------------------------- This line -> print (current Module)."Description" "\n" <- occurs in a section documenting the current[module] function. So it would seem that any following example that uses current would be of the function, and not the current variable (or whatever the thing named current is that you can assign to it). However, if I change it to include the optional parentheses: print (current() Module)."Description" "\n" it does not compile giving this error: -E- DXL: <Line:100> incorrect cast, expected (Module) -I- DXL: all done with 1 error and 0 warnings Edited: 11-Mar-2008 at 22:41 by Robert Smith |
|
![]() |
|
![]() |
|
Don't quite understand what's going on, whether 'current' is a function or a variable or both, but of the 4 lines below, only the 4th one generates an error:
print (Module current). "Description" "\n" print (Module current())."Description" "\n" print (current Module). "Description" "\n" print (current() Module)."Description" "\n" This reminds me of the guy that goes to the doctor, puts his arm above his head and then touches his ear, and says "It hurts when I do this". To which the doctor replied "Don't do that". Do this: print (current Module)."Description" "\n" Well, actually you should capture the current module at the top of your script, and then use that variable: Module mCurr = current ... print (mCurr)."Description" "\n" - Louie |
|
![]() |
|
![]() |
|
string myFunc() {return "A\n"}
int myFunc() {return 1} print myFunc int print myFunc string print (int myFunc()) print (string myFunc()) It is described inside introduction of the DXL Referencce Manual: Because of DXL's overloading facility, it is easy to write expressions that have more than one possible interpretation; that is, they are ambiguous. Casts are used to pick which interpretation is required. Casts in DXL come in two forms: expression type (type expression) In the first form, the type name can appear after the expression, as in: o = current Object In the second form, the type may come first, but the whole expression must be within parenthesis: o = (Object current) What is unclear in documentation is that the first form requires that nothing appears between expression and type, and thus only function with no parameter can be casted this way. I suppose this was introduced to allow such syntaxes without parentheses (DXL's parents seem like they hate parentheses) print fullName of current Module Item i; for i in current Folder do print type of i ------------------------- E. Piallat CeBeNetwork |
|
![]() |
|
![]() |
|
along the same lines you can have
Module currentModule // define a module handle currentModule = current Module // set to current module and also Module currentModule = current Module // define and set current module handle or Module currentModule = current // define and set current module handle All will compile quite happily and currentModule can be used later as handle to the current module and don't forget (current ModuleRef__) = currentModule // reset the current Module to the saved current module handle and both of these work print (name currentModule) "\n" or print currentModule."Name" "\n" isn't it fun ! ----------------- Gordon Woods BAE Systems (Operations) Ltd gordon.woods@incose.org |
|
![]() |
|
![]() |
|
The only time I cast using <expression Type> is when using current, as in:
print (current Module)."name" "\n" Not sure how I got started doing that but probably by seeing examples in the DXL manual. Also, when said outload it sounds better than print (Module current)."name" "\n" Other than that, I always cast via (Type expression), as in the above. As for your comments about the name of the a module, I point out that 'name' is an attribute of the module but its also available when the module is not open, and thus you need a name(mod ref) function in order to get the name when its not open. That function, might as well, allows an open Module variable but it doesn't need to. - Louie |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
current [module]
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.