MQL5Book/Include/PRTF.mqh
super.admin 1c8e83ce31 convert
2025-05-30 16:09:41 +02:00

23 lines
1.1 KiB
MQL5

//+------------------------------------------------------------------+
//| PRTF.mqh |
//| Copyright 2021, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#include "MqlError.mqh"
#define PRTF(A) ResultPrint(#A, (A))
//+------------------------------------------------------------------+
//| Helper printer returning result and checking errors |
//+------------------------------------------------------------------+
template<typename T>
T ResultPrint(const string s, const T retval = NULL)
{
const int snapshot = _LastError; // required because _LastError is volatile
const string err = E2S(snapshot) + "(" + (string)snapshot + ")";
Print(s, "=", retval, " / ", (snapshot == 0 ? "ok" : err));
ResetLastError(); // cleanup for next execution
return retval;
}
//+------------------------------------------------------------------+