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 a function in a DxlObject?
Topic Summary:
Created On: 11-Feb-2008 19:21
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.
 11-Feb-2008 19:21
User is offline View Users Profile Print this message


David Jakad

Posts: 94
Joined: 20-Jul-2007

Can you store a function in a DxlObject? If so, how exactly would you extract the function from the DxlObject?

I am looking for something like this (although this causes a fatal crash):

void fnInvoke(void f(string),string s) {f(s)}
void fnTheFunction(string s) {ack s}
DxlObject o = new()
o->"Name" = "Test"
o->"Function" = fnTheFunction
fnInvoke(addr_ (o->"Function"),"Testing")
Report this to a Moderator Report this to a Moderator
 11-Feb-2008 20:28
User is offline View Users Profile Print this message


David Pechacek

Posts: 674
Joined: 5-Dec-2006

No. The best you could do would be to store the code for the function in a string and run it with eval_(). But then you can't pass any variables to it. The function would have to be a static thing where all pertinent info is in the dxl code string

With some crafty programming you might get something useable.

Besides what use could this have?

-------------------------
David Pechacek
AAI Services Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com
Report this to a Moderator Report this to a Moderator
 11-Feb-2008 21:56
User is offline View Users Profile Print this message


Douglas Zawacki

Posts: 58
Joined: 17-Oct-2006

David,

Here is your solution, enjoy!
Report this to a Moderator Report this to a Moderator
 11-Feb-2008 22:17
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Clever.

I remind you that this only works with functions that have at least one parameter; parameterless functions cannot be used this way. If 'fnTheFunction' had no parameters, then o->"Function" = fnTheFunction would not know you are storing the address of the function and it would be interpreted to run the function and store its result in the DxlObject. Since it has no returned value you'd get some other error.

- Louie
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 0 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 0 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.