Page 1 of 1

Do you have to use Eval() to call a function name contained in a variable?

Posted: Thu Aug 22, 2024 8:50 pm
by HGAutomator
Hi,

Is there an official method other than Eval and a Code Block, or Macro Expansion "&", to call a function name contained in a variable?


So if you have a function defined with 2 parameters like

Function ThisProc( sParameter_01, sParameter_02 )
Local bReturnCode := .F.

If (condition)
bReturnCode := .T.
EndIf

Return bReturnCode

, and you place the function name and array of parameters into variables like this:

sProc := "ThisProc"
aParameters := { sParameter_01, sParameter_02 }

, what is the recommended way to call the function using these 2 variables sProc and aParameters?

Re: Do you have to use Eval() to call a function name contained in a variable?

Posted: Thu Aug 22, 2024 9:34 pm
by HGAutomator
The answer is HB_ExecFromArray.

Re: Do you have to use Eval() to call a function name contained in a variable?

Posted: Fri Aug 23, 2024 7:09 am
by edk
Thx