Finding and Fixing Errors in Included MQH, Library and Header files?

 

Hi,

I’m wondering how to determine that my mqh and library files are correct as they are not compiled? Can I run them through the compiler anyway to have my code for these files checked for errors and warnings or would they generate ‘false errors and warnings’ along with the legitimate ones?

Also I have quite a number of mq4 and ex4 files in both my ‘Include’ and ‘Library’ folder. Are any of these file types useable for either Included or Library files or have I put them there out of my lack of knowledge about this and thus can safely delete them. I have at least 6 different MT4 instances and am going to install some more so they add up. Also its best to do some ‘house keeping’ and get them removed from where they don’t belong so that they don’t get to the point where it is a monumental chore to get the inappropriate files removed from where they don’t belong and as such are unnecessary and unusable?

. . . . . (8 >) . Thanks to any and all for any assistance with this. (< 8)

They best of this HolyDay season to One and All.

Regards,

Doug

 

They are compiled - when you compile the "parent" program which includes them. Once that's done, and the included file behaves in the way that you expect, then you can relax when you include it in later programs.


CB

 
cloudbreaker wrote >>

They are compiled - when you compile the "parent" program which includes them. Once that's done, and the included file behaves in the way that you expect, then you can relax when you include it in later programs.

CB

CB is correct.

If you want, you can compile them. The result will be that you may recieve some warings. The warnings are given when the funtions in the file are not used anywhere (and the compiler can not see outside the file being compiled so it does not know you are using the function in an ea elsewhere).

Do not worry about them, you are only looking for errors.

The errors are what you are after as this is where your syntax problems are.

One the file compiles with no errors, you can include it safely in your ea.

Of course you need to remember that this does not save you from faulty logic errors, only syntax errors. (Hence CB comment above, "included file behaves in the way that you expect").

whocares

 

HI Guys,

(I’m not sure that ‘Guys’ is right, but then WhoCares? (< 8)

Being so new to this I still don’t have the syntax down pat and reliable yet, so that part will help me. Though I understand and do get warnings and errors when it refers to variables etc that aren’t in the file as it is the file that gets referred to as one would expect.

My only significant programming experience prior to this is in a tight vertical market: CNC Machining (Computer Numerically Controlled) and for understandable reasons there are many aspects of both checking and controlling the program both when coding and running them and hence the machines movements; which for obvious reasons is a necessity. I have about 5 different utilities for checking these programs and running them in virtual simulations. These all have numerous means to check, control, modify and fix errors in the CNC programs as do the numerous editors I have for coding these files. Maybe I should make a translation interface into these for checking none executable MQ files? Ahhh ChristMass is a time for dreams (< 8)

So basically other than syntax I’m on my own. Not an encouraging prospect in this point of the learning curve for me! But then this does serve to help with the learning curve as well. As with many things in Life we (hopefully) learn from our mistakes.

Do I have this right?

Thanks and wishing you both HolyDays Peace, Contentment and Happiness.

Doug

 

So basically other than syntax I’m on my own.


No! Just treat the included header files exactly as you treat the rest of your source code. Debug it using temporary Print() statements etc.

It's irrelevant that the source code is being pulled in from another file immediately prior to each compile.

You're making a meal of this, Doug.


CB

 

Hi CB,

Earlier I saw your advice about using ‘print’ statements set to get information from the program to check on it and what its current variables, results from logic statements etc.

. . . This is an excellent idea and I will use it.

If I understand you correctly, this applies to ex4 files that imports code from Include, library, header and import files and these will get checked for errors when the mq4 file gets compiled ?

 

ex4 files have nothing to do with it.


Creating an mq4 file that includes an mqh file and then compiling it means that the following happens:

1. Source code from the mqh file is copied and pasted to the top of the mq4 file

2. The amalgamated source code is compiled into a single ex4 file


I'm starting to lose the will to live, Doug!


CB

 

Hi CB,

I'm starting to lose the will to live, Doug!

Geez CB, don’t do that! Like you told me: you are taking this WAY to seriously mate!

Take a big slow breath in. Hold it. Good!

Now exhale fully and slowly. Hold it a bit. Good!

Repeat as many times as is necessary! (< 8)

.

Remember up above where I said: 'Peace, Contentment and Happiness', well now I'm doing more than 'wishing' it for you: Do it!

As I said, I’m a compassionate and empathetic guy, so here is an alternative for you CB that might greatly reduce these aggravations and stressors for you: just do my coding for me! LoL

I’m just being considerate of you CB, that’s all, really! I'm willing to make this sacrifice for your sake! Really! (< 8)

.

I think this is what I misunderstood and it threw me off:

‘If you want, you can compile them. The result will be that you may receive some warnings.’

Not your fault WhoCares, as I said, it was MY misunderstanding.


So eventually they will get checked which when they are ‘included’ in the MQ4 files and it is compiled.

I’m going to find this out when it happens; but does the actual code get imported into the parent program actually show up in the parent file and hence it will show the errors and warnings in the imported code itself when the parent program is compiled or does it just say that there are errors in the imported code files?

 
DougRH4x wrote >>

Hi CB,

I'm starting to lose the will to live, Doug!

Geez CB, don’t do that! Like you told me: you are taking this WAY to seriously mate!

Take a big slow breath in. Hold it. Good!

Now exhale fully and slowly. Hold it a bit. Good!

Repeat as many times as is necessary! (< 8)

.

Remember up above where I said: 'Peace, Contentment and Happiness', well now I'm doing more than 'wishing' it for you: Do it!

As I said, I’m a compassionate and empathetic guy, so here is an alternative for you CB that might greatly reduce these aggravations and stressors for you: just do my coding for me! LoL

I’m just being considerate of you CB, that’s all, really! I'm willing to make this sacrifice for your sake! Really! (< 8)

.

I think this is what I misunderstood and it threw me off:

‘If you want, you can compile them. The result will be that you may receive some warnings.’

Not your fault WhoCares, as I said, it was MY misunderstanding.


So eventually they will get checked which when they are ‘included’ in the MQ4 files and it is compiled.

I’m going to find this out when it happens; but does the actual code get imported into the parent program actually show up in the parent file and hence it will show the errors and warnings in the imported code itself when the parent program is compiled or does it just say that there are errors in the imported code files?

Hi Doug

It is like CB said. treat it like your normal compile. When you run the compiler, it will list the errors, no matter where they are, and you can then deal with them. And like CB said, you are making it more difficult than it has to be. Just run the compiler and deal with the errors listed. The compiler will list the errors and take you to each one to deal with (double click on the error and the compiler takes you to it in the code). If the error is in the include file the comiler will take you straight to it.

Simples

 

Hi WhoCares,

I have been and am doing that thanks. I understnad that from the amount of expereince you have versus whereI am at, it is bound to be a lot more difficult. Everyon has to start from the same plce: nowing nothing about coding MQL4, which more definately includs me. From many psotings about it, It seems that knowledge, experience adn compeitence in C++ first is of considerable as well. Alas I don't know it at all.


Enjoy the ChristMass HolyDays guys

 
DougRH4x wrote >>

Hi WhoCares,

I have been and am doing that thanks. I understnad that from the amount of expereince you have versus whereI am at, it is bound to be a lot more difficult. Everyon has to start from the same plce: nowing nothing about coding MQL4, which more definately includs me. From many psotings about it, It seems that knowledge, experience adn compeitence in C++ first is of considerable as well. Alas I don't know it at all.

Enjoy the ChristMass HolyDays guys

Hi Doug

I know how you feel. I don't know nearly as much as I would like to, but this forum is great for people who are willing to help themselves. I have spent more than a year reading articles and testing bits of code and readling the responses to peoples questions on the forum. People like CB and Phy (and others) are great, they are always ready to point you in the right direction, once they see you are willing to learn.

Just stick with it and you will get there.

Enjoy the holidays

And don't trade live uuntil at least mid Jan!

And don't trust the results of demo trades until the same time!

whocares

Reason: