Thanks tex,
The array is of a large size, potentially having a first dimension of over 100 (even 1000). With it being a dynamic array I was unsure it was possible to pass it as you suggest?
Ok now I see thanks tex,
I am attempting to pass the array values to the function like this:
myfunction(Opened);
And reference them in the array like this:
myfunction (string& O[][2]) { // and within this function have Opened[][] values available ?? }
However the values of the array when called in myfunction() are 'empty'.
Here is now the complete code example:
string Opened[][2]; void OnTimer() { int hstTotal=OrdersHistoryTotal(); for(int i=0;i<hstTotal;i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Access to history failed with error (",GetLastError(),")"); break; } ArrayResize(Opened,i+1); // populate array Opened[i][0]=DoubleToStr(OrderStopLoss()); Opened[i][1]=DoubleToStr(OrderTakeProfit()); } // for loop
string $t = "array test", Opened[0][0];
Print($t); // is successfully printing the array value myfunction(Opened); } // end OnTimer myfunction (string& O[][2]) { // and within this function have Opened[][] values available ?? // example: string $test = "test array ",O[0][0]; Print($test); // returns - "test array " with no output value for the array }
Perhaps a simple script example of how arrays are passed by reference will help?
#property strict void OnStart() { int MyArray[2][2]={0,1,2,3}; MyFunction(MyArray); } void MyFunction(int &array[][]) { Print(array[0][0]); Print(array[0][1]); Print(array[1][0]); Print(array[1][1]); }
knave your a legend!
Thanks my friend for the example. My problem was adding parameter 2 value in the function array declaration. Now my code is working fine.
Again many thanks :-)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi. In researching this I see this was once not possible pre. build 600. My question is whether it is now possible post build 600? structures and classes ? My objective is to pass the array values populated in one function into another function with a global declared array?
For example:
thanks in advance.