Print statments or 'Alerts' for Debuging

 
Print statments or 'Alerts' for Debuging?
 
DougRH4x wrote >>
Print statments or 'Alerts' for Debuging?

Hi Doug

CB and Phy recommends Print. I use a combination of Comment, Alert and Print depending on the situation.

If I want to see the value of a variable, to verify that it is as expected, I will typically just show it on the chart with Comment. I will then change the code to move to the next variable until I am satisfied with the results.

It is better to use Print ifter each calculation because it the code fails you can see where (by looking at the last Print).

I guess it is a matter of what works for you. Experiment with various options until you get the result that you need.

whocares

 

HI again WC,

I do want it as a deugging / feedcak mechanisim and want a more immediate response as oppose to 'print' watatemnt so that I will know exactly where and waht the problem &/or unexpected result is. It seems tro me that if I used an Alert in conjunction with 'GeLastError' funtion that it may rpovide the specific info that I want tofind out so that I can correct it.

 

Doug,


How do you think that Alert(GetLastError()) would give you a more "immediate" response than Print(GetLastError())?

You've really lost me this time, Doug.

The difference between Alert(), Comment() and Print() is in HOW the information is delivered, not WHAT or WHEN.


CB

 
I suspect Doug means it's more easily accessible with an alert than printing? In that case I suggest u make a custom print function that flushes on each write and use a tailing program to watch the log in real time. Personally I use a freeware called baretail (http://www.baremetalsoft.com/baretail/) but there are many others...
 
I installed cygwin for tools like tail.
 

f.w.i.w, I've been caught out using comment() to see the state of variables, because it slows things down horribly. If the comment() is placed in a loop somewhere it can seem that the program has crashed when it hasn't. Ticks still arrive as seen in the Market Watch but the chart stops updating. It comes right if you wait forever. I now only use comment in situations where it is called occassionally.

Jellybean

 
phy:
I installed cygwin for tools like tail.

It's a bit of overkill to install cygwin just for tailing and pointless for anybody who is not familiar with linux/unix os's... But yeah, that would work to. I wonder why MQ didn't make log files (both experts and journal logs) flush on each write. It would make the log files so much more usable.

 
gordon:
I suspect Doug means it's more easily accessible with an alert than printing? In that case I suggest u make a custom print function that flushes on each write and use a tailing program to watch the log in real time. Personally I use a freeware called baretail (http://www.baremetalsoft.com/baretail/) but there are many others...

Just so: I want the program to halt execution and then to be notified of an error when it occurs so that I know exactly what the error is and exactly where it is ocuring,, suing RunTime errors and immediately displaying them with Alert(GetLastError) or otherwise. IIs there a 'DeBug' mode or ??? that will accomplish this ? What ever will do this function as opposed to putting it in the log file and carrying on.

Do try to keep up CB ! LoL (< 8)


Happy New Year to All

 

There is no debug facility in MT4.

No capability to Step Into, Step Out, Halt Execution based on Breakpoints, set a list of preset variables etc.

You must manually debug using Print(), Comment() or Alert() at key points in your code, to check logic flow and/or content of variables.

Regarding which one of the 3 you choose - as I've already said, they all produce the same result - just in different reporting styles.


Doug, we've already informed you in the answers to this post that "THERE IS NO DEBUG MODE".

You'd also find that information in these example forum posts, simply by typing "Debug" into the forum search:

https://forum.mql4.com/17536

https://forum.mql4.com/26124

https://forum.mql4.com/19573

https://forum.mql4.com/15757


And in this article:

https://www.mql5.com/en/articles/1473


CB

 

there is no DOBUG-Mode in MT4 or MT5 or in the forum

whether in this or in that direction you are trying to find one or ask to implement one especially made for you

maybe this is hard to accept for you, DOBUG ...

take it like a man.

Reason: