![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Non local variable access in cb function Topic Summary: Problem occurs only in included file Created On: 29-Nov-2005 10:25 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
Hello @ all,
I've got the following problem: If I place a kind of list dialog into the the main file everything works fine. (see Main.dxl) But if I place the list dialog into an inc file, e.g. for re-use reasons, the DXL engine reports the following errors: -E- DXL: <SingleSelectListDlg.dxl:21> non local variable access (selection) -E- DXL: <SingleSelectListDlg.dxl:21> non local variable access (str_array) -E- DXL: <SingleSelectListDlg.dxl:22> non local variable access (selection) -E- DXL: <SingleSelectListDlg.dxl:25> non local variable access (selected_item) -E- DXL: <SingleSelectListDlg.dxl:25> non local variable access (str_array) All variable access - both parameter variables and the local vairable selected_item are not visible to the cb function "onItemSelection()". But why? Can anyone help me please? (see Main2.dxl + SingleSelectionDlg.inc) Best, Oliver ------------------------- Greetings,<BR>Oliver<BR><BR><BR>Oliver Roepke<BR>Axis Engineering AG, Munich |
|
![]() |
|
![]() |
|
I'm pretty sure you can't nest functions, which would probably account for the errors you're seeing.
You should be able to delcare everything (DBs, DBEs, functions) at the top level, and declare the parameters passed into SingleSelectListDlg as globals, then only show the dialog box when you call the function in the include file. You can still return the selected_item from that new (smaller) function. Hope that helps a little, Paul. ------------------------- Paul dot Tiplady at TRW dot com TRW Automotive |
|
![]() |
|
![]() |
|
Hi Oliver,
it seems to be a simple problem of the placement of the #include statement. The #include directive is done by preprocessor, so it is the same, as you copy the text of included file at the place of #include statement. In the code of your included file, you refer to variables, which are declared later in the Main2.dxl file, so they are not know at this time .... And of cause Paul is right - you can not create callback functions within other functions! Greetings Reik Schröder ------------------------- Evosoft GmbH for Siemens Industry Sector Berlin, Germany Edited: 29-Nov-2005 at 11:02 by Reik Schroeder |
|
![]() |
|
![]() |
|
quote:This is not true. It all depends on where the DBE element variables are declared. As shown in my example below, nesting functions is entirely legal, however the the placement of variable declaration limits where they can be used. It would seem like any variable declared within a function would also be available to a nested function, however this is not the case. Declare these DBE variables globally so all functions will be able to use them. -Dennis |
|
![]() |
|
![]() |
|
Thanks for that clarification Dennis. I wasn't sure whether it could be done, so I've never attempted it. It's never really seemed important enough to try!
I'm guessing Oliver's intention is to be able to encapsulate everything about the dialog box in a single function (tell us why, Oliver!), but your solution seems just as good to me. I'd probably still split out the functions so they're not nested, because the encapsulation is effectively pushed to the file level by the need to keep the DBs and DBEs global. Regards, Paul. ------------------------- Paul dot Tiplady at TRW dot com TRW Automotive |
|
![]() |
|
![]() |
|
Hi! quote: |
|
![]() |
|
![]() |
|
Here's my last msg again since I made a mistake using the quoted message: ------------------------- Greetings,<BR>Oliver<BR><BR><BR>Oliver Roepke<BR>Axis Engineering AG, Munich |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Non local variable access in cb function
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.