Jump to content

Indirect function call


obrienj
 Share

Recommended Posts

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
Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...