FileWriteString()

 

I have the following function in my #include.mqh file ..... properly referenced and other functions of the include ARE being accessed and utilized.

void Write (string argFileName, string argString)   // routine to log transaction to separate log file
        {
              int handle = 0;
              
         handle=FileOpen(argFileName, FILE_BIN|FILE_READ|FILE_WRITE);
         Print ("Handle: " + handle);
         
         if(handle < 1)
         {
              Print("Can not open file error ",GetLastError());
              return(0);
         }
         
         
         FileSeek(handle, 0, SEEK_END);
         FileWriteString(handle, argString , 1000);
         FileFlush (handle);
         FileClose(handle);
  
  return(0);

And in the EA, I am 'calling' this function with the following code:

 LogFileName = ("genesis66_"+ (TimeToStr(TimeCurrent(),TIME_DATE))+".txt" );
                     if (UpdateExternalLogFile)
                     {
                       LogString = (TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS)+": "+"Genesis Initialized");                      
                       Write (LogFileName,LogString);
                       
                }

My question is this. Why doesn't this code APPEND each write to the file? The only thing I can get this routine to perform is a sporatic recreation of the file containing a single line. I reference several sources for the code and thought my logic was correct, but I am beating my head against the wall on this simple project. Any ideas?

 
try no binary
 
WHRoeder:
try no binary
 

thanks for the tip. I noticed after I logged the request by choosing BIN over CSV the file developed long ways instead of vertically as the BIN did not have 'new lines' in it. It was working just the right into infinity.

You suggestion most definitely worked. thanks..

Reason: