import a function from an "mqh" file

 

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.

 
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

 
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.

 
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...