You can't do that in mql5.
There are several workaround, for example :
// FILE 1. Name: my_include_file.mqh string get_name(); string get_welcome_message(string name) { string name = get_name(); return StringFormat("Hello %s, welcome to our home!", name);
and
// FILE 2. Name: my_script.mq5 #include <my_custom_includes\my_include_file.mqh> string get_name() { return "Cyberglassed"; } void OnStart() { string welcome_message = get_welcome_message("Cyberglassed"); }
Another workaround, depending of your actual problem :
// FILE 1. Name: my_include_file_1.mq5 string get_name() { return "Cyberglassed"; }
// FILE 2. Name: my_include_file_2.mqh #include <my_custom_includes\my_include_file_1.mqh> string get_welcome_message() { string name = get_name(); return StringFormat("Hello %s, welcome to our home!", name); }
// FILE 3. Name: my_script.mq5 #include <my_custom_includes\my_include_file_2.mqh> void OnStart() { string welcome_message = get_welcome_message(); }
angevoyageur:
Another workaround, depending of your actual problem :
Thank you very much angevoyageur
it helps me! ;)
You are welcome.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello folks, I cannot figure out how to do in MQL5 the following I can do in C++
I always get the error:
'get_name' - function must have a body my_include_file.mqh 3 8
Am I doing some error or is there is workaround to have the possibility to declare a function like that before arrive to the location where it is implemented?
Thanks, Cyberglassed.