Bug in FileWriteString (MQL4) - page 2

 
Malik Arykov:
everything works as it should ;-)
uint  FileWriteString(
   int           file_handle,    // File handle
   const string  text_string,    // string to write
   int           length=-1       // number of symbols
   );

Yes, use the length of symbols in text as the third parameter, there is no bug.

In some sisuations,we need to create file with a fixed bytes,therefore we have to pass a fixed number for the third paremeter.

 
Ziheng Zhuang:

Yes, use the length of symbols in text as the third parameter, there is no bug.

In some sisuations,we need to create file with a fixed bytes,therefore we have to pass a fixed number for the third paremeter.

    int len = 64;
    string str = "1234567";
    string tail; // string filled with zeros
    StringInit(tail, len - StringLen(str));
    FileWriteString(handle, str + tail, len);

content must match the length or vise versa ;-)

 
Malik Arykov:

content must match the length or vise versa ;-)

This is a work-around, but the built-in function 'FileWriteString' has an option to do it if the parameter is greater than the length of the string, it is poorly documented, and the result is a different from MQL4 to MQL5.

 
But... This work-around solves the problem (fixes the bug ;-)
 
Malik Arykov:
But... This work-around solves the problem (fixes the bug ;-)

It kills the bug ;D

Reason: