![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Cast? Topic Summary: DXL Reference manual cast contradiction? Created On: 10-Mar-2008 23:21 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
I am referencing the DXL Reference Manual for DOORS version 8.1.
In Chapter 10, Modules, section Module references, Setting current module it has this example code current = Module module Is the code on the right side of the = a cast? What is the Data Type of the current variable? Thanks Robert |
|
![]() |
|
![]() |
|
Robert, I think the manual is deceptive. (They didn't do a good job of explaining)
Following code will work without a cast -- dxl can figure out that the code is referencing a module. Line three where there is a cast causes a syntax error. Module module = current current = module //current = Module module // this line causes a syntax error. |
|
![]() |
|
![]() |
|
The example you site has the same form as most of the other refereneces in the DXL manual. In this case, setting the current module looks like this:
current = Module module Since 'module' is in italics it means that's a variable. That line means that setting the current module requires the word 'current' on the left side of the equal sign and requires a reference of type 'Module' on the right. It does not mean you type that line exactly as written. For example, scripts that must run from an open module typically have this at the top: Module mCurr = current Somewhere down in the code you may end up doing this: current = mCurr Since variable 'mCurr' is of type 'Module' it satisfies the DXL manual. I never thought about it before, but yes its curious that 'current = Module mod' appears to use a variable of name 'current'. I don't think its really a variable, since there are other 'current' things such as 'Folder', 'Project', and 'Object'. It would be more precise if they would have a function to do it, perhaps 'setCurrent(Module mod)'. Understand that there seems to be several functions whose name is 'current()', of types 'Module', 'Folder', 'Project', and 'Object' (there are others). DOORS usually figures out which one you use by context; all the following are the same: Module mCurr = current Module mCurr = current() Module mCurr = Module current Module mCurr = Module current() (I have a preference for using empty braces () for functions that don't have parameters, just so its obvious I'm referencing a function not a variable). There are times, however, where context may be ambiguous in which case you must explicitely cast. If you allow implicit declarations: Linked = target(lnk) is ambigous. Is 'Linked' of type 'Object' or 'Module' or 'ModName_'? You get the first 'target()' function defined, whichever that is. Turns out in v5.2 you get 'Object' but in v7.1 you get type 'ModName_'. Instead you'd do one of these: Linked = Object target(lnk) Object Linked = target(lnk) to make sure you are using the correct 'target'. I cannot think right now of an example where explicity casting is required when you turn implicit declarations off. - Louie |
|
![]() |
|
![]() |
|
Thanks for the reply.
Since 'module' is in italics it means that's a variable. That line means that setting the current module requires the word 'current' on the left side of the equal sign and requires a reference of type 'Module' on the right. It does not mean you type that line exactly as written. I cannot remember any other language manual having examples like that. Normally they would show Module myModule current = myModule or current = myModule // myModule is a variable of type Module I never thought about it before, but yes its curious that 'current = Module mod' appears to use a variable of name 'current'. From the perspective of someone trying to learn DXL, it was an extremely poor choice to have a function current, particularly in a language where () is optional, and then have something on the left side of equations called current. Module mCurr = current Module mCurr = current() Module mCurr = Module current Module mCurr = Module current() What is occuring on the right side of the last two examples? If its a cast, that violates the rules of casting that the DXL Reference manual for 8.1 gives on page 18 - "Casts". you get type ModName_ I saw ModName_ in the DXL Reference manual. I searched the PDF file and could find no place where they defined ModName_????? Edited: 11-Mar-2008 at 18:21 by Robert Smith |
|
![]() |
|
![]() |
|
Robert, I think the manual is deceptive. (They didn't do a good job of explaining)
Thanks for the reply. It's good to hear you say the manual has at least one issue. I was breezing through the DXL Reference manual on the language basics, and then when I get to the DOORS specific stuff it's been a nightmare. |
|
![]() |
|
![]() |
|
That's not an 'example', its definiing its use. That is, you set the current module by using 'current' on the left, and equal sign, and then some 'Module' reference on the right. Further down you see examples.
My mistake, yes its within parenthesis: (Module current) and (Module current()). None of the types are really 'defined' so its no surprise you don't see ModName_ defined in its own section. You can eventually deduce what its doing by examining all the places its referenced in the manual. If you find the module (handle) command (section Module references), you find that this works: ModName_ mn = module("/MyProject/MyFolder/MyModule") That gives you a crude handle on the module without having to open it. I know I use ModName_ references when dealing with Links (target(lnk) and source(lnk)), but cannot think of other used for it right now. - Louie |
|
![]() |
|
![]() |
|
Thanks again for the reply.
That's not an 'example', its definiing its use. That is, you set the current module by using 'current' on the left, and equal sign, and then some 'Module' reference on the right. Further down you see examples. OK, I get it, not example code but statement definition. I think it should be shown as current = <Module variable> "None of the types are really 'defined' so its no surprise you don't see ModName_ defined in its own section." It's really good to see you say that because as I was reading sequentially through the manual I was looking forward to getting to the areas where they defined the non Fundamental data types. At some point I couldn't wait any longer and went to find them. I was scratching my head thinking that it appeared that they didn't exist. But I kept thinking that they must be somewhere and that I just wasn't finding them .... Someone for Telelogic support said regarding data types with an underscore that they are are typically used by developers and that typically you do not need to know about them... |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Cast?
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.