FileWrite() New line Problem

 

Hil, 

 I am having problem with file written EA as it seems like only a single line is written. 

 Is following code ok ? 

   handle=FileOpen("TestFile.csv", FILE_CSV|FILE_WRITE, ';');
   if(handle>0)
    {
     FileWrite(handle, Ask,Count1,Count2,X,TickCount);
    // Alert(" Write to File : ", handle);
     FileClose(handle);
    }
  
     if(handle<0)
     {Alert("File Open Failed ! ");}
 }
 

 And also why is file written by MT4 not visible in Win7 explorer ? Folder persmission issues (whch i just cannot figure out why ? ) 

 

Thx

Jim 

 
JimRobo:

Hil, 

 I am having problem with file written EA as it seems like only a single line is written. 

 Is following code ok ? 

 And also why is file written by MT4 not visible in Win7 explorer ? Folder persmission issues (whch i just cannot figure out why ? ) 

Did you read the documentation ?   Click me -->  FileOpen()    why would you expect more than one line ?  are you trying to write a line and then add a second and third , etc ?  

"If FILE_WRITE does not combine with FILE_READ, a zero-length file will be opened. If even the file contains some data, they will be deleted. If there is a need to add data to an existing file, it must be opened using combination of FILE_READ | FILE_WRITE."

 

Sounds like UAC issues . . .  don't install MT4 in Program Files. 

 
  1. You open the file, WRITE only, so the file is now empty.
  2. You write one line and close the file. Of course "it seems like only a single line is written. "
   int      APPEND   = FILE_CSV|FILE_WRITE|FILE_READ;
   int      handleOPT   = FileOpen(nameOPT, APPEND, '~');
   if(handleOPT < 1){   int      GLE = GetLastError(); ... }
   FileSeek(handleOPT, 0, SEEK_END);
   FileWrite(handleOPT, opt.parameters);
   FileClose(handleOPT);
 
Ok .. got it .. Thx guys .. 
Reason: