Array to file

 

I have an array (example[]), that i want to print to file. What i am doing wrong? The data.csv file appears in folder, but it's empty.

‌‌This is the code:

‌In main section:

input string InpFileName="data.csv";
input string InpDirectoryName="SomeFolder";
string path=InpDirectoryName+"//"+InpFileName;


double example[] = {0,5,5,5,2,1,0,4,4,4,5,7,0,0};

‌In OnInit section:

handle=FileOpen(path,FILE_CSV|FILE_WRITE,',');

In  OnCalculate section:

FileWriteArray(handle,example,0,WHOLE_ARRAY);
 
Magaiver:


handle=FileOpen(path,FILE_CSV|FILE_WRITE,',');
FileWriteArray(handle,example,0,WHOLE_ARRAY);


FileWriteArray only works for BIN files.

 

Thank you for your answer. I have one more question:

How to read those bin files? Notepad gives me values like this: 

  ò?ffffffú?ÍÌÌÌÌÌô?       @      ð?              @      @      @      @      @        aTR' ‰ó?>íð×dó?B•š=Њó?9EGrùó?F%ušˆó?      4@        ‌

 

Probably best just to stick with the CSV file.

// FileWriteArray(handle,example,0,WHOLE_ARRAY);
for(int i=0; i<ArraySize(example); i++) FileWrite(handle,example[i]);