Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get a return value from "mac(function)" ?
#1
What i need is to run a function by variable and get its TRUE/FALSE return value.

The only way i could find that would run a function dynamically was mac(function), but it appears to return true if it was found/executed, rather than returning the return values of the function itself.

I can do it with the new thread setting a global variable like this:

Caller
Code:
Copy      Help
function str'name

name = "function1" ;; temp

int+ async_result;
async_result=0;

int hThread=mac(name)
wait 0 H hThread

if(async_result) out "True"
else out "False"

Function1
Code:
Copy      Help
function#
;;checks something, returns true
int+ async_result = 1;
Is there a better way i can do this?
#2
Use reference argument(s).

Caller
Code:
Copy      Help
function str'name

name = "Function75" ;; temp

int RET
int hThread=mac(name "" &RET)
wait 0 H hThread

if(RET) out "True"
else out "False"

Function Function75
Code:
Copy      Help
function# int&RET
RET=0
1
RET = 1;

Also try RunTextAsFunction and RunTextAsFunction2.
#3
Thank you! Big Grin


Forum Jump:


Users browsing this thread: 1 Guest(s)