![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Executing another DXL script from a DXL script Topic Summary: Created On: 11-May-2004 17:06 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|||||
My main DXL script creates the dialog in which the user enters the name of the DXL script that is to be executed.
So, the flow of the program is as follows: - User executes the command from a menu in Doors - Dialog shows up in which the user enters the full path of the dxl script that is to be executed - User presses the "Apply" button on the dialog which calls the Apply(DB win) function - In this function I obtain the full path of the dxl script that is to be executed and assign it to a string [The structure of the dxl script that the user specified is a single function with a call to that function at the end of the script] - If I can simply include this script in my main dxl everything would be fine BUT I get the error when I try to use something like this: string anotherDXL = get(anotherDXLDBE) or ( string anotherDXL = "\"" get(anotherDXLDBE) "\"" ) #include anotherDXL Then I want to continue the execution of the function Apply() in my main dxl. Here is the error: -E- DXL: <Line:125> could not open include file (anotherDXL) (No such file or directory) -I- DXL: <Line:125> all done with 1 error and 0 warnings Is there a way to make the #include work in this case or maybe there is another way to achieve what I am trying to do? Thanks. |
|||||
![]() |
|||||
![]() |
|||||
The attached script allows you to run DXL scripts on selected modules.
This is a slightly modified version of a script originally written by Jeremy. I find this a very useful tool
------------------------- Tony Goodman http://www.smartdxl.com Edited: 20-Jun-2005 at 14:35 by Tony Goodman |
|||||
![]() |
|||||
![]() |
|||||
even though #include can appear in an if-then statement, this doesn't mean that it is dynamic. The DXL parser processes the #include statement before running the DXL - so you can't pass a parameter to the #include as you can with a function.
here is an alternative... string sFile = "somefile.dxl" string sEvalStr = "#include <" sFile ">" eval_(sEvalStr) what this does is to create a new DXL context and run sEvalStr in it. Because it runs in a new DXL context - any declarations in somefile.dxl will not be available to the calling context. e.g if somefile.dxl contains... string sHelloWorld = "Hello" print sHelloWorld then... string sEvalStr = "#include <somefile.dxl>" eval_(sEvalStr) print sHelloWorld ...will throw DXL errors at line 3 because sHelloWorld is not defined. but... string sEvalStr = "#include <somefile.dxl>" eval_(sEvalStr) ...works just fine. if you use evalTop_ instead of eval_ then it runs the DXL in the top DXL context, so next time you open a DXL window and run "print sHelloWorld" - this will work. This is because each new DXL context derives from the top DXL context. historically, eval_ has not been supported because of problems with DXL contexts in DOORS (including memory leaks, crashes etc). It works fine in DOORS 7 - except in obscure circumstances. Ross. |
|||||
![]() |
|||||
![]() |
|||||
It is possible to return stuff (a string, at least) from the context in which the 'eval_' DXL runs, using 'return_' in the 'eval_' DXL. See the API manual, section 4.
And if you can work out a simple set of instructions for using it, I'm sure a lot of people would be very happy! ![]() ------------------------- Paul dot Tiplady at TRW dot com TRW Automotive |
|||||
![]() |
|||||
![]() |
|||||
Since I need the access to the code in the include file(I need to be able to call a function in this file multiple times), I will have to use evalTop_ and run it in the top context. Am I right?
|
|||||
![]() |
|||||
![]() |
|||||
yes, but if you you are running user DXL to load the DXL then you will have to put the load operation in one menu item, and the execution of the loaded functions in another.
this is because each invocation of a user menu, for example, creates a new DXL context. So the order of operations is... (1)user menu A invokes a new DXL context. evalTop_ loads the selected DXL file into the top context (2)user menu B is invoked and loads a new DXL context which derives from the top context which by now includes the declarations needed by menu B. if menu A is invoked again with the session then a dxl error will be raised telling you that all the declarations in the DXL file already exist. If you define a global boolean variable then you can avoid running evalTop_ on the file twice. Trouble is that each file you potentially want to load will need to have a common set of declarations. Also, if the files do share common declarations then you will only be able to evalTop_ one of them per session. Getting messy, isn't it? DXL doesn't support the notion of late-binding i.e binding the definition to the declaration at run time. DOORS supports function overloading but not function redefinition - once a definition is wound into the DXL context it can't be unwound or replaced. I am fairly certain that DXL doesn't support assignable function pointer variables either, which might have been another way around the problem (you can pass function references, but not store pointers to functions) |
|||||
![]() |
|||||
![]() |
|||||
If you need to run the code in the include file multiple times, you could read the include file into a string (or buffer, preferably) and do an eval_ on the string (or buffer) as many times as you like -- each one would be in a new context, so there would be no danger of duplicating definitions.
------------------------- Paul dot Tiplady at TRW dot com TRW Automotive |
|||||
![]() |
|||||
![]() |
|||||
I did not find the script you described as attached. Can you re-post it or mail it to me (sherman.rf@pg.com)?
Thanks |
|||||
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.