import a function from an "mqh" file

To add comments, please log in or register
parham.trader
656
parham.trader  

Hi

I'm writing an script and I want to use a function which I've written previously in an "mqh" file, in my script and I don't want to do a simple copy-paste and put the code in my script, instead I want to use #import to use the previously written function in my script. As I read the documentation, it stated that the #import can only be used to import functions from .dll and .ex4 files so I'd appreciated if anyone can help me know whether I can use the #import for ".mqh" files as well or not.

Please be noted that I can easily use #include to have my .mqh file codes in my script, but because some minor problems I'd prefer not using #include for having my .mqh file codes in my scripts.

Your kind guidance is highly appreciated.

Mladen Rakic
139661
Mladen Rakic  
parham.trader:

Hi

I'm writing an script and I want to use a function which I've written previously in an "mqh" file, in my script and I don't want to do a simple copy-paste and put the code in my script, instead I want to use #import to use the previously written function in my script. As I read the documentation, it stated that the #import can only be used to import functions from .dll and .ex4 files so I'd appreciated if anyone can help me know whether I can use the #import for ".mqh" files as well or not.

Please be noted that I can easily use #include to have my .mqh file codes in my script, but because some minor problems I'd prefer not using #include for having my .mqh file codes in my scripts.

Your kind guidance is highly appreciated.

Use #include

#import is for something else

parham.trader
656
parham.trader  
Mladen Rakic:

Use #include

#import is for something else

Thank you for your kind answer,
May I know what it is exactly for?

As I describe in my previous post, I'd prefer an alternative solution for #include.

Mladen Rakic
139661
Mladen Rakic  
parham.trader:

Thank you for your kind answer,
May I know what it is exactly for?

As I describe in my previous post, I'd prefer an alternative solution for #include.

If you do not want to use #include, then you should not save the code in mqh files (since mqh files are, by common convention, include files in MQL https://www.mql5.com/en/docs/basis/preprosessor/include)
Documentation on MQL5: Language Basics / Preprocessor / Including Files (#include)
Documentation on MQL5: Language Basics / Preprocessor / Including Files (#include)
  • www.mql5.com
with the content of the file WinUser32.mqh. Angle brackets indicate that the WinUser32.mqh file will be taken from the standard directory (usually it is If the file name is enclosed in...
To add comments, please log in or register