Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
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
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 15-Jan-2008 19:09
User is offline View Users Profile Print this message


David Jakad

Posts: 94
Joined: 20-Jul-2007

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.
Report this to a Moderator Report this to a Moderator
 16-Jan-2008 16:08
User is offline View Users Profile Print this message


Marcel van der Laan

Posts: 15
Joined: 21-Sep-2007

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
Report this to a Moderator Report this to a Moderator
 16-Jan-2008 16:35
User is offline View Users Profile Print this message


David Jakad

Posts: 94
Joined: 20-Jul-2007

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.
Report this to a Moderator Report this to a Moderator
 16-Jan-2008 17:19
User is offline View Users Profile Print this message


Eric Piallat

Posts: 13
Joined: 10-Dec-2007

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.
Report this to a Moderator Report this to a Moderator
 18-Jan-2008 17:58
User is offline View Users Profile Print this message


David Jakad

Posts: 94
Joined: 20-Jul-2007

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:
Report this to a Moderator Report this to a Moderator
 18-Jan-2008 22:16
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

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
Report this to a Moderator Report this to a Moderator
 24-Jan-2008 09:51
User is offline View Users Profile Print this message


Marcel van der Laan

Posts: 15
Joined: 21-Sep-2007

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
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.