Sign in to follow this  
Followers 0
obrienj

Indirect function call

4 posts in this topic

#1 ·  Posted (edited)

Anybody have an example of calling a function via the contents of a variable.

That is, if I have the following:

local $vara

$vara = Foo

;  ????? what is the form of the invocation of Foo using the variable and passing a parameter  ?????

Func Foo($parm)

    ; do something with $parm
    return(-1)
EndFunc

The question is:

what is the form of the invocation of Foo using the variable and passing a parameter

I tried:

$rc = $vara("data")

but I got syntax errors.

I know how to do this in C, C++, Java and C#, but I can't seem to get it in Autoit.

I have a rather large project where doing this is a requirement.

Regards,

Jim

Edited by obrienj

Share this post


Link to post
Share on other sites



I think you might be over thinking it. Try this.

local $varA

$varA = Foo("this is a test param")

msgbox(0,"$varA = ",$varA)

Func Foo($parm)
    return MsgBox(4,"The Parameter Provided",$parm)
EndFunc

If you absolutely have to be able to execute a variable as a literal string, then read the help file for the Execute() function.

Share this post


Link to post
Share on other sites

obrienj was explaining the functionality of Call() function.

local $vara

$vara = "Foo"

$rc = Call($vara, "data")

Func Foo($parm)

    ; do something with $parm
    return(-1)
EndFunc

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

trancexx,

Thank you. I knew it had to be there somewhere.

Regards,

Jim

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0