stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Just made an IDE for MQL4
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=627
Page 22 of 32
Author:  gaheitman [ Tue Oct 23, 2012 4:18 pm ]
Post subject:  Abbreviations

A couple other things I am working on...

I have modified mql.properties so that we have our own abbreviations file in <SciTE Directory>\abbrevs. I added the following lines to mql.properties:

Code: Select all

# abbreviations
abbreviations.$(file.patterns.mql)=$(SciteDefaultHome)/abbrevs/mql.abbrev
Abbreviations are entered in the form (without the brackets):
<shortcut>=<lots of stuff with embedded newlines and tabs, whatever else you want but all on one line>

So, a simple abbreviation to put in a header for a function could look like this:

Code: Select all

//+=//+------------------------------------------------------------------+\n//|  \n//+------------------------------------------------------------------+
Then, when you type "//+" and press Ctrl-B you'll get the expanded text.

Code: Select all

//+------------------------------------------------------------------+
//  
//+------------------------------------------------------------------+
These abbreviation puts in the ol' default text when creating a new script in Empty4, with a few modifications:

Code: Select all

/script=//+------------------------------------------------------------------+\n//|                                                 <Scriptname>.mq4 |\n//|                                    Copyright © 2012, <your name> |\n//+------------------------------------------------------------------+\n#property copyright "Copyright © 2012, <yourname>"\n\n//+------------------------------------------------------------------+\n//| script program start function                                    |\n//+------------------------------------------------------------------+\nint start()\n  {\n   return(0);\n  }\n//+------------------------------------------------------------------+
While working with these abbreviations I came across a problem with the sidebar code. It was throwing an error when I highlighted an abbreviation on the panel. Apparently, it was supposed to be showing me a preview as a calltip/annotation. I ended up turning off a bit of codepage translation to make it work, so who knows what far reaching impact this might have! I've included the updated sidebar.lua script.

One more tip, if you have your own code, formats, whatever that you want turned into abbreviations, you can paste them into a blank document and then format them via search and replace. Just search for "\r\n" and replace with "\\n". Make sure to select the option in the replace dialog to "Transform backslash expressions". This will collapse everything to one line.

George
Author:  cybernick [ Sun Nov 04, 2012 10:27 am ]
Post subject:  Re: Just made an IDE for MQL4

is there a way to view the Help predefined functions / variables at the bottom like in the mql editor?
Author:  phaholj [ Mon Nov 05, 2012 12:35 pm ]
Post subject:  Re: Just made an IDE for MQL4

How do i install and run the IDE for MQL4?
Author:  gaheitman [ Mon Nov 05, 2012 1:40 pm ]
Post subject:  Re: Just made an IDE for MQL4

phaholj wrote:How do i install and run the IDE for MQL4?
That was answered earlier in the thread. I'd recommend reading the whole of it, but if you are pressed for time search the thread for "install".

George
Author:  phaholj [ Tue Nov 06, 2012 8:16 am ]
Post subject:  Re: Just made an IDE for MQL4

gaheitman wrote:
phaholj wrote:How do i install and run the IDE for MQL4?
That was answered earlier in the thread. I'd recommend reading the whole of it, but if you are pressed for time search the thread for "install".

George

Thanks
I have read the whole thread now and i have lot of info and it is now working.
This is great, i will stop using MetaEditor and focus on the code.
Author:  phaholj [ Tue Nov 06, 2012 11:18 am ]
Post subject:  Re: Just made an IDE for MQL4

gaheitman wrote:
dietcoke wrote:
gaheitman wrote:
BTW, I've added the rest of the reserved words to the api file, which is why I got so many choices to begin with.

I haven't mentioned this yet, but I'm loving this editor!
George

George,

would you mind posting your mods?
Certainly. First off, I have hacked together a way to create an api file from source using the existing sidebar functionality.

You need to tell SciTE to use a secondary mql.api file. I named it _mql.api and it is in the same directory as the first. To do this, modify mql.properties --

This:

Code: Select all

api.$(file.patterns.mql)=$(SciteDefaultHome)\api\mql.api
becomes this:

Code: Select all

api.$(file.patterns.mql)=$(SciteDefaultHome)\api\mql.api;$(SciteDefaultHome)\api\_mql.api
The attached Sidebar.lua (uploaded as sidebar.txt since the board doesn't allow .lua) file adds an item to the context menu of the Functions/Bookmarks pane to "Save api". When selecting this, it will basically write the contents of that pane to the _mql.api file. Unfortunately, SciTE doesn't immediately re-read api files, you have to switch to a different file type (in another buffer) and then switch back. Working on that....

Context menu:
IMG_41.gif
After running "Save api" on MultiBob, here's the Calltip (after the autocomplete, of course, since I had the case wrong :>)

Calltip from MultiBob:
IMG_42.gif
I also changed the file mask to be *.mq4 so the directory view is immediately useful (for mql programming, that is).

EDIT: Updated mql.txt to include all constants.

George
Where do you place the SideBar.lua?
On which directory?
Author:  gaheitman [ Tue Nov 06, 2012 12:05 pm ]
Post subject:  Re: Just made an IDE for MQL4

phaholj wrote:
Where do you place the SideBar.lua?
On which directory?
It's in the \additions folder off of wherever you installed the program. There will be a SideBar.lua there already.

George
Author:  phaholj [ Tue Nov 06, 2012 2:54 pm ]
Post subject:  Re: Just made an IDE for MQL4

gaheitman wrote:
phaholj wrote:
Where do you place the SideBar.lua?
On which directory?
It's in the \additions folder off of wherever you installed the program. There will be a SideBar.lua there already.

George

Thanks
Its now working.
It also display only *.mq4 file on the FileMan tab of the SlideBar
Author:  gaheitman [ Tue Nov 06, 2012 5:06 pm ]
Post subject:  Re: Just made an IDE for MQL4

phaholj wrote:
gaheitman wrote:
phaholj wrote:
Where do you place the SideBar.lua?
On which directory?
It's in the \additions folder off of wherever you installed the program. There will be a SideBar.lua there already.

George

Thanks
Its now working.
It also display only *.mq4 file on the FileMan tab of the SlideBar
Yes, I set the filter to start that way. If you right click on a file in the box, you can set it to show all files. If you find the start behavior annoying, you'll have to edit sidebar.lua. Just search for *.mq4 and replace it with the extension you would like (or *.*, of course).

George
Author:  SteveHopwood [ Thu Nov 08, 2012 11:01 pm ]
Post subject:  Re: Just made an IDE for MQL4

w633, when I try to compile a script, I get these error messages:

2;76;C:\Program Files\Cowboy IBFX Trader 4\Cowboy IBFX demos\Software development\Software development\experts\scripts\TradeHedgeBUYALL.mq4;10:1;'WinUser32.mqh' - cannot open the program file
2;76;C:\Program Files\Cowboy IBFX Trader 4\Cowboy IBFX demos\Software development\Software development\experts\scripts\TradeHedgeBUYALL.mq4;11:1;'stdlib.mqh' - cannot open the program file

What can I do?

:D
All times are UTC Page 22 of 32