File Writing Question

 

Trying to create a csv file.  Now, I know this isn't useful; but in order to figure out a problem; you need to break it down into it's smaller components.  This is the component I'm trying to get work.

The output should be:

1,2,3
1,2,3
1,2,3

 The output I get is:

1,2,31,2,31,2,3

 Here is the code.  Any ideas?

#property strict

#include <Files/FileTxt.mqh>

CFileTxt LogFile;

void OnStart()
  {
   LogFile.Open(StringConcatenate("MyFile",".csv"),FILE_READ|FILE_WRITE);
   LogFile.WriteString(StringConcatenate("1",",","2",",","3"));
   LogFile.WriteString(StringConcatenate("1",",","2",",","3"));
   LogFile.WriteString(StringConcatenate("1",",","2",",","3"));
   LogFile.Close();
   Print("Done!");
  }

 Thanks in advance!

 

Hi!

you have to insert NEW LINE at the end of a line.

LogFile.WriteString(StringConcatenate("1",",","2",",","3","\n"));
 
eddie:

Hi!

you have to insert NEW LINE at the end of a line.

Sort of.  I got working.  Here's the code:

#include <Files/FileTxt.mqh>

CFileTxt LogFile;

void OnStart()
  {
   LogFile.Open(StringConcatenate("MyFile",".csv"),FILE_READ|FILE_WRITE);
   LogFile.WriteString(StringConcatenate("1",",","2",",","3","\r\n"));
   LogFile.WriteString(StringConcatenate("1",",","2",",","3","\r\n"));
   LogFile.WriteString(StringConcatenate("1",",","2",",","3","\r\n"));
   LogFile.Close();
   Print("Done!");
  }
Reason: