Sign in to follow this  
Followers 0
ophelius

Function Address

3 posts in this topic

Hi,

Is it possible to store the address of a function so I can call it based on a variable? For example, let's say I have 3 functions, a(), b(), and c(), and the program needs to call one of those based on a variable x. So first i would allocate an array F[3] and store the addresses of all 3 functions like this: F[0] = @a(), F[1] = @b(), F[2] = @c() and now I can simply do this: call F[x]. And if x = 0, the a() would be called, etc.

I'm aware that I can do: If x = 0, then call a(), etc, but that's not what I need. Thanks

Share this post


Link to post
Share on other sites



$a = "try1"
Call($a)

Func try1()
consolewrite("it works!"&@crlf)
EndFunc

maybe this?

I preffer using other methods like adding a parameter into the function, but this works.

Share this post


Link to post
Share on other sites

Great, that works. I wasn't aware you can call a function like that. Thanks

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