Help with FileReadArray and a multidimensional array variable

 

Hi all,

I have a one-line CSV file with 6 integer values in it.  I am trying to read it and write it to a two-dimensional array, but I can't get my code to compile.  Please help!

Code:

       int handle;
       handle=FileOpen("Strat10.csv", FILE_CSV|FILE_READ,';');

       if(handle>0)
       {
         Strat1[0][4]=0; //resets the improbable trigger.
         FileReadArray(handle, Strat1[1], 0, 6);  //this line fails to compile.
         FileClose(handle);
       }


Strat10.csv has 6 integer values.

My array, Strat1, is a 2 x 6 array (initialized as a global variable, Strat1[2][6]).  I want to write the 6 values from the CSV file into the second line of my array.  I've been running with this array variable for a wihle, but this is my first time trying to read information into my array from the hard disk.  Can you provide any suggestions as to how to do this?


Thanks!

 

What you need is an equivalent to

int array1[2][6], array2[6];

array1[1] = array2;

While this is easy in many/most other languages it's not possible in MQL. You need to write your own function to assign arrays to arrays. First read your values into a standard int array. Then assign this array to your multi-dimensional target array:

FileReadArray(handle, tmp_array, ...);
ArraySetIntArray(multi_array, 1, tmp_array);

Compile both library files contained in the ZIP file. ArraySetIntArray() needs the "ExpertSample.dll" from your original MetaTrader installation in your "experts\library" folder to work. I do not include it because you already have it.

Files:
Reason: