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

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
HGAutomator
Posts: 197
Joined: Thu Jul 16, 2020 5:42 pm
DBs Used: DBF

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

Post 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?
HGAutomator
Posts: 197
Joined: Thu Jul 16, 2020 5:42 pm
DBs Used: DBF

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

Post by HGAutomator »

The answer is HB_ExecFromArray.
edk
Posts: 999
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

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

Post by edk »

Thx
Post Reply