![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Can you store functions in a Skip List ??? Topic Summary: Created On: 15-Jan-2008 19:09 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
Can you store functions in a Skip List ? And, if so, how would you retrieve and trigger those functions from the Skip List ? If it's possible, would every function need to return the same type? Essentially I want something like:
void tmpFunction() {} Skip skpList = create void function1() {ack "Function 1"} void function2() {ack "Function 2"} void function3() {ack "Function 3"} put(skpList,1,function1) put(skpList,2,function2) put(skpList,3,function3) for tmpFunction in skpList do { tmpFunction() } You may ask, why would I want to do this? I have a very large, complex dialog box, with many tabs, listViews, treeViews, etc. Much of the data cannot be initialized until after the dialog box is realized. I would like to build a skip list of "initialization functions" that all run after the dialog box is realized. I cannot directly initalize the data because many of the dialog box elements are created within other nested functions, and therefore the DBEs are not global variables. |
|
![]() |
|
![]() |
|
Hi David,
Yes something like this is possible, using an undocumented feature, addr_. The following code works if you cut-and-paste it in your DXL window. This is the basis of object oriented programming with DXL ![]() Good luck with it. Regards, Marcel |
|
![]() |
|
![]() |
|
This is a big help. Thanks.
I am guessing the "addr_" refers to the memory address where the function is stored. Are there more object-oriented features (documented or undocumented)? I've noticed if you define a function within another function, any local variables defined in the parent function are not accessable in the child function. Although, in most cases, you can pass the local variables into the nested function. Although, it can get tricky when the nested function is a callback that must follow a certain structure. |
|
![]() |
|
![]() |
|
Hi,
Some of those "undocumented" features are in fact documented inside the DOORS API manual. It is the case of addr_, eval_, return_ and evalTop_. And of course, the case of the truly API-specific perms (Inter-process communication related). IMHO, the "DXLObject" type is not documented anywhere however. It is described in many threads of this forum. |
|
![]() |
|
![]() |
|
Marcel,
I've noticed that if the functions in the skip list do not take any variables, you quickly run into memory management problems and DOORS fatal crashes. For example, the following code causes my DOORS to die: |
|
![]() |
|
![]() |
|
OK, this is well beyond my normal expertise, but here goes.
When you use a function parameter A inside a call to another function B, it usually means execute that function A and send the results to function B. That's why your code gets 'Hello World' before it aborts, fn1 gets CALLED as you try to put it in the skip list. Since fn1 has no returned value, the put triggers serious DXL errors. I failed in several attempts to insert the addr_ of the function. I brushed off the cob-webs of some other addr_ DXL scripts I've downloaded over the years, in this case some 'Calendar' program by Reik Schroeder and used it for an example. What I've just now come up with, and I hope some of the clever folks can confirm deny or enhance it, is that if you have a function that has call parameters and use that function in the parameters of another function and do NOT include any parameters, then DOORS seems to understand you are calling with the function and not with the results of the function. In your case, since fn1 and fn2 have no parameters at all, DXL gets confused when you try to use the function in a call to another function. The attached is basically your code, but I've added a useless int parameter to the original functions. It does what you want. - Louie Edited: 18-Jan-2008 at 22:25 by Louie Landale |
|
![]() |
|
![]() |
|
Hello all,
Indeed, calling a void parameter function seems to give problems. The DXL interpreter sees that there fn1 is a valid function call without parameters and hence calls it immediately. Note that you will also run into problems if you want to invoke a function with parameters when a function exists with the same name without parameters, since this latter function will be invoked 'too early'. But this is probably avoidable. Using a dummy parameter seems to be the quickest work-around, even though it does not seem to be entirely 'clean'. Hope it works for you, though. Marcel |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Can you store functions in a Skip List ???
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.