Discussion of article "Promote Your Development Projects Using EX5 Libraries" - page 2

 

In general, one function from import returns an interface, and the interface is accessed without penalty.

It is better to store the set of functions in mqh file.

 
Urain:

When will yours be ready?

I've already got mine and they're in the neuronette. I probably won't be reposting it soon, I'm planning to conquer the world right now.

Honestly, I'll read your posts a little more and I'll quit MT5 altogether.

Be patient, everything will be fine :)

 

I think not everyone knows that MetaEditor 5 has a special command that allows you to (literally)"generate an include file from exported functions of the current file".

Generating include files

В MetaEditor предусмотрена специальная функция генерации включаемых файлов (*.mqh) из экспортируемых функций текущего файла. Для запуска генерации, необходимо выполнить команду Сформировать mqh-файл" в меню "Сервис".

Generation process

Generation of an mqh-file is performed in the following way:

  • The current open file contains all functions with the exportpostmodifier .
  • An include file with #importdirective and description of the found functionsis generated .
  • If no exported function is found, a corresponding message is displayed.
  • If the source file is located in the /Libraries folder, the module name in the #import directive will have a relative path from the /Libraries directory. If the file is located in another directory, only the name of the ex5-file is substituted in #import.

If the current file is an include file (*.mqh), the generation command does not work.

Generation path

The directory where the mqh file is generated depends on the location of the source file:

  • If the current file is located in the /Libraries directory or one of its subdirectories, the include file will be generated at the root of the /Include folder.
  • If the source file is located in some other directory, the include file is generated in the same location.

Using mqh files

The function of generating include files allows you to easily provide other users with access to your functions without revealing their source code. All you need to do is to provide the generated mqh file, as well as the ex5 file where the function implementation is located.

 

You may be interested to know that MetaEditor 5 has the special command that allows you to generate include files of the exported functions in a current file.


Generating Include Files

MetaEditor has a special feature for generating include files (*.mqh) on the basis of exported functions of the current file. To start this function, you should execute the "Generate Include File Generate Include File" command of the "Tools" menu.

The Process of Generation

The generation of a mqh file is performed in the following way:

  • In the currently open file, all functions with the export post modifier are searched for.
  • An mqh file that contains the #import directive and the description of the functions found is generated.
  • If no exported functions are found, the corresponding dialog is displayed.
  • If the source file is located in the /Libraries folder, then the module name in the #import directive will contain the path relatively to the /Libraries directory. If the file is located in another directory, #import will include only the name of the ex5 file.

If the current file is an include file (*.mqh), the command of generation is disabled.

The Path of Generation

A folder where mqh files are generated depends on location of the source files:

  • If a source file is in the /Libraries directory or in one of its subfolders, the include file will be generated in the root of the /Include folder.
  • If a source file is in another folder, the include file will be generated in the same place.

Using MQH Files

The function of generating include files allows to easily share your functions with other users without exposing the source code. To do it, it's enough to provide the generated mqh file and the ex5 file where the functions are implemented.

 
Where is the source of "3. Initialization of Variables in .ex5 File"? (SuperClass.mqh; SuperClass.mq5, etc...)
 
VincentX:

Where is the source of "3. Initialization of Variables in .ex5 File"? (SuperClass.mqh; SuperClass.mq5, etc...)
i ask thesame question
 
Renat:
...
Is it planned to implement export for Class or something similar ?
 
angevoyageur:
Is it planned to implement export for Class or something similar ?
Yes, but not now.
 
Renat:
Yes, but not now.
Thank you.
 

At least some possibility to export classes.

Will it work in MT4?