Saturday, December 24, 2011

Prettify / Beautify / format your MQ4 code in 30 seconds (or any code)

Here’s a really easy way to format your code. Formatting code makes it easier to read the logic flow, this little program automatically indents, fixed spaces and tabs. After my EA's get to big and add the debugging to the mix, my formatting starts to slowly go out the window. I run this every now and then, it takes under 30 seconds. This is a command line formatter.

Go get the file from here or here

These links take you to http://astyle.sourceforge.net. The page at one of these links will describe the switches you can use with the command line formatter. I've chosen some that work for me to get your started.

Instructions
1. unzip and find a file called AStyle.exe (windows) in the “bin” directory
2. put the file in the experts directory
3. open up a command prompt window (start>run>cmd)
4. drag the AStyle.exe file into the window
5. add a space then type this after the file name -A2 -s3 --mode=c
6. Add a space then drag and drop the file you want formatted, press enter
7. Done. You see the original was renamed with a “orig” extension.
How easy is that!

No comments:

Post a Comment

Let's hear what you have to say!

Disclaimer

The information presented on this site is for educational and entertainment purposes only. This site contains no suggestions or instructions that you must follow, do your own research and due diligence before committing your cash to the markets. Your on your own.