ophelius Posted September 3, 2011 Share Posted September 3, 2011 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 Link to comment Share on other sites More sharing options...
monoscout999 Posted September 3, 2011 Share Posted September 3, 2011 $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. Link to comment Share on other sites More sharing options...
ophelius Posted September 3, 2011 Author Share Posted September 3, 2011 Great, that works. I wasn't aware you can call a function like that. Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now