Page 1 of 2
Starting the function of the variable value
Posted: Mon Oct 27, 2014 11:33 am
by Eugene Lutsenko
How to run on the execution of the function, the name of which is given in the form of a variable value?
Re: Starting the function of the variable value
Posted: Mon Oct 27, 2014 12:44 pm
by rdonnay
I do not understand your question. Please clarify.
Re: Starting the function of the variable value
Posted: Mon Oct 27, 2014 1:42 pm
by Eugene Lutsenko
For example, the program has a function: F1_8(). There are variable: mFunct = "F1_8()". Usually this function to start the program I am writing: F1_8(). And how do I start it for execution with the function name as a variable value mFunct? @mFunct why something does not work.
Re: Starting the function of the variable value
Posted: Mon Oct 27, 2014 2:52 pm
by rdonnay
For example, the program has a function: F1_8(). There are variable: mFunct = "F1_8()". Usually this function to start the program I am writing: F1_8(). And how do I start it for execution with the function name as a variable value mFunct? @mFunct why something does not work.
Re: Starting the function of the variable value
Posted: Mon Oct 27, 2014 9:08 pm
by Eugene Lutsenko
This is me at once and tried. Somehow, when you compile the message: "error XBT0250: Incomplete expression"
Re: Starting the function of the variable value
Posted: Tue Oct 28, 2014 2:02 am
by Tom
"F1_8()" can't be a STATIC function if you try to do this.
Re: Starting the function of the variable value
Posted: Tue Oct 28, 2014 6:20 am
by rdonnay
Show the exact code.
Re: Starting the function of the variable value
Posted: Tue Oct 28, 2014 7:29 am
by Tom
This works:
Code: Select all
FUNCTION Main()
cTest := "MyFunc()"
&(cTest)
RETURN nil
FUNCTION MyFunc()
MsgBox('Test')
RETURN nil
Re: Starting the function of the variable value
Posted: Tue Oct 28, 2014 2:13 pm
by Eugene Lutsenko
Thank you, Tom!
Live and learn! About the fact that you need to write a function name in parenthesis, I never would have guessed. Or rather, I remembered that so you can do with the files, but never did so with the function name. And there is still a macro substitution. Such a design I had never used, but now I will, because it is very convenient in some cases. And most importantly - works great!
Re: Starting the function of the variable value
Posted: Tue Oct 28, 2014 5:03 pm
by rdonnay
I forgot the parenthesis. Sorry.
BTW - Here is how you pass local parameters to a macro-compiled function: