0

I supposed it would be much easier, but I cant use a two-dimensional array as parameter in a simple mql4 function and insert elements in it. I don't know where the problem is.

I have a function declared like this:

void insert_array_in_multi(double simple_array[], double &multi_array[][]){

...
ArrayResize(multi_array,1);

ArrayCopy(multi_array[x][0],simple_array); // Here I want to copy the one-dimension array into the multidimensional one, in "x" position. And here is where I get the ERROR when executing.

// I use "multi_array[x][0]" because is the way I don't get errors when compiling; if I use  "multi_array[x]", meaning I want the one-dim array to be copied in the x pos of the multi-dim array, I get the error message "wrong dimension"

...
}





The other function calling this one, is like:

double bidiarray[0][10];

... as I put new elements, I resize the array to an array with 10 or more (primary) elements

... create a one-dimensional array like this:

double simple_array[10] = ...

... and then call to the previous function:

insert_array_in_multi(simple_array,bidiarray);

...

}

The error message I get is "1 parameter for ArrayCopy function must be array"... But, it is... Isn't it?

Somebody knows how to do it?

Thanks in advance.

PD: It fails when executing, not when compiling

Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58
Alberto Martín
  • 439
  • 13
  • 26

1 Answers1

0

I tried testing function with following signature and it compiles, so I think it will work. Give it a try:

int foo(int something[][])
{
   return (0);
}

int somenumber[5][5];
somenumber[0][0]=7;
foo (somenumber);
gerrytan
  • 40,313
  • 9
  • 84
  • 99
  • I'll paste my code, maybe my question wasn't wide enough, sorry. Give me 5 minutes to edit it. – Alberto Martín Jan 15 '13 at 04:04
  • I've realized the problem is more related with the ArrayCopy function, so instead of editing this question, i'll accept your answer as good, since your answer was logic, and ask about the copy of arrays in a new question. – Alberto Martín Jan 15 '13 at 07:56