using NotePad++ to edit and compile

 

Hi, finally I managed to use NotePad++ (google) to edit and compile mt4-files with some surprises :)

1) I created one folder for both mt4-compiler: 32 and 64 bit. (you'll find the HowTo in: Editor=>F1=>Search:"Compiling")

2) In that folder I created as well two folders MQL4 and MQL5!

3) In the MQL4 folder I placed links to the mt4 code-folders (Include, Experts, ..)

4) In the MQL5.folder I placed just links to MT4's Include and Libraries folder.

5) For the links I use Schinagl's Link File Extension (google) but may be it is not needed Win7-link might do it as well (a kind of a personal historical residual)

6) In Notepad++ (abrev. Npp) I installed MppExec (it's a plugin).

6) If you now want to compile a mt4 file ..NppExec -> Execute (F6 does not work :() a little windows open with some sample code.

    You just need:

NPP_SAVE
C:\..\compiler\mql64.exe "$(FILE_NAME)" /i:C:\..\compiler\

".." has to be replaced by the correct part of the path to the folder with the compiler and both MQL-folders

7) save the two lines!

8) In NppExec' options window I checked:

    



9) I set the Console Output Filters this way:


Ok - done :)

To get the highlights of mt4 I crearted the attached file, which you have to "import" in Npp: Language => Define your Language.. => IMPORT

If you now compile an EA or Indicator the ex4-file is created in the Experts\ resp. Indicators\ folders.

It compiles mq4 (I haven't tried mq5).

It even compiles mqh but code of b500-- will throw errors ONLY if you compile the mqh-files.

If you compile mq4-files with 'old' mqh you'll get no error.

If you have mqh files that include other mqh-Files the compiler needs the MQL5-folder even if you have only mq4 files

Now your mql4-EA can include MQL5 mqh like e.g. Statistica.mqh:  Functions - library for MetaTrader 5

(the editor compiles it as well!)

Finally I found out that if an include01.mqh includes other mqh-file and your EA includes them as well everything is loaded only once - it works, I haven't had any troubles so far..

Good luck,

Gooly

PS: Another goody of NotePad++: There is a Plugin Translate, so I guess you can translate Russian (or English or..) comments and text in to your favourite language - but I haven't used it so far.


PPS: I was informed that it could be that you have to switch FILE_NAME and the i:Path options - try it yourself:

NPP_SAVE
C:\..\compiler\mql64.exe /i:C:\..\compiler\  "$(FILE_NAME)"
Files:
mql4_b600.zip  8 kb
 
Thanks for sharing
 
You're very wellcome
 

Thanks for sharing. Where were you pre build 600 !   The MT4 editor back then was truly primitive, I used to write code in NotePad++ and copy and paste into Metaeditor to compile. 

Have you tried working your magic on Scintilla? 

 

 

 

ED 

 
rod178:

Thanks for sharing. Where were you pre build 600 !   The MT4 editor back then was truly primitive, I used to write code in NotePad++ and copy and paste into Metaeditor to compile. 

Have you tried working your magic on Scintilla? 

Probably yes, as Scintilla is only a component and the front page of Notepad++ site reads

Based on the powerful editing component ScintillaNotepad++ is written in C++ and uses pure Win32 API and STL which ensures a higher execution speed and smaller program size. 

 
rod178:

Thanks for sharing. Where were you pre build 600 !   The MT4 editor back then was truly primitive, I used to write code in NotePad++ and copy and paste into Metaeditor to compile. 

Have you tried working your magic on Scintilla? 

ED

i don't use Scintilla even though I have heard about it.

What might be interesting could be Geany - but I don't know whether you can define a mql4 highlighting or not

 
gooly:
You're very wellcome

Not a troll, just curiosity. I developed hundred of codes with MetaEditor and never feel the need to use an other editor for mql4/5. Though it's far from perfect of course.

For example I use mql5 storage, the debugger and the profiler, which are integrated.

Can you made a short description of what are the advantages (disadvantages) to use Notepad++ (which I also use but not to code mql4/5 except when I need the "Compare" plugin) ?

Thank you.

 
angevoyageur:

Not a troll, just curiosity. I developed hundred of codes with MetaEditor and never feel the need to use an other editor for mql4/5. Though it's far from perfect of course.

For example I use mql5 storage, the debugger and the profiler, which are integrated.

Can you made a short description of what are the advantages (disadvantages) to use Notepad++ (which I also use but not to code mql4/5 except when I need the "Compare" plugin) ?

Thank you.

1) I started to like Notepad++ as soon as the mt4 compiler claims a  bracket is missing. Npp can count the brackets and so I can find a lot faster the missing thing.

2) Npp compares code - as you said.

3) fold code (mt4 still can't do that)

4) I can sort source code like sort this on Column 23

This:
extern string Sym1 = "EURUSD";
extern string Sym2 = "GBPUSD";
extern string Sym3 = "USDJPY";
extern string Sym4 = "USDCHF";
extern string Sym5 = "USDCAD";
extern string Sym6 = "AUDUSD";
extern string Sym7 = "NZDUSD";
extern string Sym8 = "EURJPY";
extern string Sym9 = "EURGBP";

becomes:

extern string Sym6 = "AUDUSD";
extern string Sym9 = "EURGBP";
extern string Sym8 = "EURJPY";
extern string Sym1 = "EURUSD";
extern string Sym2 = "GBPUSD";
extern string Sym7 = "NZDUSD";
extern string Sym5 = "USDCAD";
extern string Sym4 = "USDCHF";
extern string Sym3 = "USDJPY";

and back sorting again on column 1:

extern string Sym1 = "EURUSD";
extern string Sym2 = "GBPUSD";
extern string Sym3 = "USDJPY";
extern string Sym4 = "USDCHF";
extern string Sym5 = "USDCAD";
extern string Sym6 = "AUDUSD";
extern string Sym7 = "NZDUSD";
extern string Sym8 = "EURJPY";
extern string Sym9 = "EURGBP";
5) There is a plugin for code snippets. 6) If a file is changed by another file Notepad++ asks me: Load the changed version or not? Mt4 just ignores it. 7) The editor has a lot more option to manipulate the text/code. 8) I can have two windows to work/compare/use two different files/versions. 9) Many more options to search in files not just one. 10) Clipboard History 11) Unfortunately it seems that Translate-Plugin is not working but this would be really a great thing as many don't speak English or Russian very well. Go and complain, they might fix it? 12) RegEx for search (and replace)  ... Npp is nothing but a very good editor, while Metatrader is financial software (server and client) that has as well an editor, not bad but not as rich as Npp.  
 
gooly:
angevoyageur:

Not a troll, just curiosity. I developed hundred of codes with MetaEditor and never feel the need to use an other editor for mql4/5. Though it's far from perfect of course.

For example I use mql5 storage, the debugger and the profiler, which are integrated.

Can you made a short description of what are the advantages (disadvantages) to use Notepad++ (which I also use but not to code mql4/5 except when I need the "Compare" plugin) ?

Thank you.

1) I started to like Notepad++ as soon as the mt4 compiler claims a  bracket is missing. Npp can count the brackets and so I can find a lot faster the missing thing.

2) Npp compares code - as you said.

3) fold code (mt4 still can't do that)

4) I can sort source code like sort this on Column 23

Thank you for this "short" explanation.
 

Let me add that you can get a function list of your own functions quite easily:

1) (in Win7) load C:\Users\...\AppData\Roaming\Notepad++\functionList.xml

2) add this:  <association userDefinedLangName="mql4" id="mql4_sytax"/>

    here:

<NotepadPlus>
        <functionList>
                <associationMap>
....
                     <association userDefinedLangName="mql4" id="mql4_sytax"/>
                </associationMap>

3) add this in the next section:

      <parsers>
         <parser id="mql4_sytax" commentExpr="((/\*.*?\*)/|(//.*?$))">
            <function
                mainExpr="^[\t ]*[\w:]+([\s]+[\w]+)?([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+)([\w_]+[\s]*::)?(?!(if|while|for))[\w_]+[\s]*\([^\)\(]*\)([\s]*const[\s]*)?[\n\s]*\{"
                displayMode="$functionName">
                <functionName>
                    <nameExpr expr="(?!(if|while|for))[\w_~]+[\s]*\("/>
                    <nameExpr expr="(?!(if|while|for))[\w_~]+"/>
                </functionName>
            </function>
         </parser>

(I just copied them from c further below and there is as well one for c++ - may be valid for mql5.)

I f you now click on the Function List button (or in menu => View => Function List) you see a window with the list of all your functions of the actual mql4 or mqh file.

A click on a function and you are there!

Here the example of Statistics.mqh:


You can sort the functions alphabetically :)

 
Thanks Gooly... A very convincing post in favour of NotePad++. Just like to add that I find it hard to go past WinMerge for comparing source files, even though it is not integrated with any particular editor.
Reason: