Better DLL help...

 
Hello,

Would it be possible to get a better sample or at least more documentation on the DLL sample that you do provide?

For instance:

What the heck are the printf functions in the .cpp code doing? They don't seem to do anything...
Can you debug custom DLL's while working with MT4? Maybe using attach process?
A step by step guide to each of the types in MT4 and the corresponding C++ types to use for parameters and return values
Why can't a make a function that takes no parameters?
Why does the first call that I make to the DLL always return null, but subsequent calls work just fine?

For instance:

I have:

MT4_EXPFUNC char* __stdcall UTCTime(int foo)
  {
    /* Get UTC. */
    char tmpbuf[128];
    __time64_t ltime;
    struct tm *gmt;
    _tzset();
    _time64( &ltime );
    gmt = _gmtime64( &ltime );
    strftime( tmpbuf, 128,
        "%Y.%m.%d %H:%M", gmt );
 
   printf("UTCTime is \"%s\"\n",tmpbuf);
   return(tmpbuf);
  }

I have the int param because the MQ4 compiler complains when I try to call UTCTime() without a parameter.
Where does that printf("UTCTime is \"%s\"\n",tmpbuf); go?? STDOUT I assume, but where is that in the context of MT4?
Why, everytime I use this call, with the following MQL4 code:

string strUTCTime;
strUTCTime=UTCTime(1);
It always returns a time like this: 2006.08.08 00:00 if it is the very first call into the dll. All subsequent ticks give the correct time (such as 2006.08. 08 08:33). I assume it is some kind of problem with the time function, but I can't tell because I can't use the debugger or know where printf's come out.

HELP!!! MT4 is great, but this one aspect of it could be documented much more heavily.

Thanks in advance...

Cubesteak
 
Our sample is sufficient - all possible passed parameters and returned types are considered. Learn it closely.

See also article 'How to Use Crashlogs to Debug Your Own DLLs'
 
Please take no offense, but I find your answer extremely disappointing. How am I to learn the sample when there is no documentation with it?

If no documentation will be forthcoming, would you at least please answer my questions?

Are you saying that anything that ISN'T covered in there can't be done? What about passing a datetime type? Must I use an MQL conversion function to put it to a string first?

Also, PLEASE do explain what the printf's in the C++ code do - where do they print to? With that one bit of info, I could move further along because I could then debug much more efficiently.

I've have indeed read article 157 on using crash logs, but I'm not getting a crash so that doesn't help.

Please, kindly reconsider...

Best regards,
cs
 

cubesteak wrote:
Please take no offense, but I find your answer extremely disappointing. How am I to learn the sample when there is no documentation with it?

Just read sources


Are you saying that anything that ISN'T covered in there can't be done? What about passing a datetime type? Must I use an MQL conversion function to put it to a string first?

Why? Datetime is long integer number of 4 bytes. The value represents the amount of seconds elapse from 00:00 Jan 1, 1970. Please read https://docs.mql4.com/basis/types/datetime


Also, PLEASE do explain what the printf's in the C++ code do - where do they print to?

There were prints to my debug console. You can remove printfs. You can insert OutputDebugString calls


I could then debug much more efficiently.

Just use Visual Studio debugger. What about breakpoints?


I've have indeed read article 157 on using crash logs, but I'm not getting a crash so that doesn't help.

You've asked about debugging
 

Are you saying that anything that ISN'T covered in there can't be done? What about passing a datetime type? Must I use an MQL conversion function to put it to a string first?

Why? Datetime is long integer number of 4 bytes. The value represents the amount of seconds elapse from 00:00 Jan 1, 1970. Please read https://docs.mql4.com/basis/types/datetime


You Are very right. Thank you, I should have seen that.


Also, PLEASE do explain what the printf's in the C++ code do - where do they print to?

There were prints to my debug console. You can remove printfs. You can insert OutputDebugString calls

Thank you, that is very helpful!!


I could then debug much more efficiently.

Just use Visual Studio debugger. What about breakpoints?

Ahh... That is what I had hoped to do. I hadn't been able to find a way to do it, but your info has prompted me to review that further. Knowing that it was possible, I was able to now find a solution. Thank you for the information! It is greatly appreciated!!



If anyone reading this thread wonders how to use VS to debug a custom, this may help. (ext. link to: http://www.cubesteak.net/2006/08/how-to-debug-custom-dlls-with-mt4/)

 
Sorry. Your link does not work because final slash.

http://www.cubesteak.net/2006/08/how-to-debug-custom-dlls-with-mt4
Reason: