Starting the function of the variable value

This forum is for eXpress++ general support.
Message
Author
User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Starting the function of the variable value

#1 Post 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?

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Starting the function of the variable value

#2 Post by rdonnay »

I do not understand your question. Please clarify.
The eXpress train is coming - and it has more cars.

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Starting the function of the variable value

#3 Post 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.

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Starting the function of the variable value

#4 Post 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.

Code: Select all

&mFunct
The eXpress train is coming - and it has more cars.

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Starting the function of the variable value

#5 Post by Eugene Lutsenko »

This is me at once and tried. Somehow, when you compile the message: "error XBT0250: Incomplete expression"

User avatar
Tom
Posts: 1234
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Starting the function of the variable value

#6 Post by Tom »

"F1_8()" can't be a STATIC function if you try to do this.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Starting the function of the variable value

#7 Post by rdonnay »

Show the exact code.
The eXpress train is coming - and it has more cars.

User avatar
Tom
Posts: 1234
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Starting the function of the variable value

#8 Post by Tom »

This works:

Code: Select all

FUNCTION Main()
cTest := "MyFunc()"
&(cTest)
RETURN nil

FUNCTION MyFunc()
  MsgBox('Test')
RETURN nil
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Starting the function of the variable value

#9 Post 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!

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Starting the function of the variable value

#10 Post by rdonnay »

I forgot the parenthesis. Sorry.

BTW - Here is how you pass local parameters to a macro-compiled function:

Code: Select all

&(myFunc)(a,b,c,d)
The eXpress train is coming - and it has more cars.

Post Reply