![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Define global variables Topic Summary: Created On: 14-Feb-2007 10:30 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
I try to define some global variable.
I checked this forum and found this trick:
const string NUMERO_GLOBAL_VARIABLE = "globalNumero";
// create variable 'globalNumero'
if (!null checkDXL "string s = "NUMERO_GLOBAL_VARIABLE";\n") {
evalTop_ ("string "NUMERO_GLOBAL_VARIABLE" = \"000\";");
}
I try to use it inside my dxl but the code doesn't compile unless the previous code is executed once (in standalone way).
I know I could define global vars in startup.dxl but I want to simplify the install of my dxl.
With startup.dxl, I must say to users ti edit this file, add an include then continue the installation of the dxl...
So I try this:
const string NUMERO_GLOBAL_VARIABLE = "globalNumero";
const string gNumero = "test";
// create variable 'globalNumero'
if (!null checkDXL "string s = "NUMERO_GLOBAL_VARIABLE";\n") {
evalTop_ ("string "NUMERO_GLOBAL_VARIABLE" = \"000\";");
}
evalTop_ ("gNumero = "NUMERO_GLOBAL_VARIABLE";");
print gNumero;
It doesn't work !
And if I run a second time, I have an "Internal Error, please submit a problem report" !
Is there a way to avoid modification of startup.dxl (and declare my variable of course) ?
|
|
![]() |
|
![]() |
|
Hi Vincent,
I think you refer to my posting here As I have written there, the code should be inserted into Module open trigger. So it will be executed before your script starts. The problem is in evalTop_, the code will be executed when script ends! So the variable is at least defined in second run of your script. Another option is to place a file in startup folder in config directory - so the user s only need to place a file there instead of editing an existing one. Greetings Reik ------------------------- Evosoft GmbH for Siemens Industry Sector Berlin, Germany |
|
![]() |
|
![]() |
|
I'm fairly sure that's not quite right: I believe when a script starts it gets all its global information and then proceeds. If that script changes the global environment then that change applies to all future scripts, but not this one since it already got its globals. If this script is on hold I believe a different script will see the global, even if the first hasn't actually finished.
But, that doesn't help much. - Louie |
|
![]() |
|
![]() |
|
Hi Louie,
what do you mean with script is on hold? Are you talking about show (DB)? You are right, it seems that the evalTop_ code is executed on calling show function, but that may not help you to declare global varaibles within your script?! I think the only way of having these global variables without modifying the startup stuff is to use a trigger (open Module) - but then the global variable is first available when you opened at least one module before (open project triggers do not work anymore as you had explained in another thread). The really usefull thing on this trigger implementation is, that it will run in an extra context outside your script, so it can finish before your script starts ... Greetings Reik ------------------------- Evosoft GmbH for Siemens Industry Sector Berlin, Germany |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Define global variables
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.