File Writing Question

Back to topics list To post a new topic, please log in or register
avatar
147
nondisclosure 2015.12.11 21:23
 

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!

avatar
108
eddie 2015.12.12 10:38 #
 

Hi!

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

LogFile.WriteString(StringConcatenate("1",",","2",",","3","\n"));
avatar
147
nondisclosure 2015.12.14 17:32 #
 
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!");
  }

 

Back to topics list  

To add comments, please log in or register