Download MetaTrader 5

Execute a string as a method?

To add comments, please log in or register
Publish your application in the Market - 7 million potential clients will see it
rod178
273
rod178 2014.04.27 04:58 
string methodString= "MyMethod()";
//execute methodString; ??????
How to execute a string as a method?


Keith Watford
Moderator
9625
Keith Watford 2014.04.27 05:08  
rod178:
How to execute a string as a method?


  if(methodString== "MyMethod()")
     MyMethod();             
rod178
273
rod178 2014.04.27 05:19  
GumRai:


Not the solution I was looking for

I desire to enter the methods dependent on variable values created. This would include overloading.

Alain Verleyen
Moderator
30740
Alain Verleyen 2014.04.27 09:48  
rod178:


Not the solution I was looking for

I desire to enter the methods dependent on variable values created. This would include overloading.

You then have to use OOP and pointers.
rod178
273
rod178 2014.04.27 13:19  
angevoyageur:
You then have to use OOP and pointers.


Yes, that is an option, although I was hoping that a more direct approach was available, as is in some other languages.

eg

eval 'MyMethod()'    # Ruby code to execute a method from  a string
Alain Verleyen
Moderator
30740
Alain Verleyen 2014.04.27 15:08  
rod178:


Yes, that is an option, although I was hoping that a more direct approach was available, as is in some other languages.

eg

Unfortunately not.
To add comments, please log in or register