![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
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 |
![]() |
![]()
|
![]() |
|
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") |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
David,
Here is your solution, enjoy! |
|
![]() |
|
![]() |
|
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 |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Can you store a function in a DxlObject?
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.