Return array from function - it is possible?

 

Hi guys,

Is possible return whole array from function?

My test code idea:

double Array1[500];

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   Array1=test();
   return(0);
  }

//+------------------------------------------------------------------+
double test()
{
  double retArr[500];
  ArrayInitialize(retArr,100);
  return (retArr);
}
 

RaptorUK: ok, I can send array as parameter to function and need return whole arra from functon to main code.

ArrayMainCode= functionABC(); // ArrayMainCode is equal array calculated in function

I don´t know possible, maybe I have any error my syntax...

 
endy5:

RaptorUK: ok, I can send array as parameter to function and need return whole arra from functon to main code.

ArrayMainCode= functionABC(); // ArrayMainCode is equal array calculated in function

I don´t know possible, maybe I have any error my syntax...

No, you do this . . .

double Array1[500];

int start()
  {
   functionABC(Array1);
   return(0);
  }


void functionABC(double& retArr)
   {
   ArrayInitialize(retArr,100);
   }
 

but it will do filling all element array retArr on value 100 and array Array1 will be zero. I want bring retArr from function to Array1 - as return value from function return( ???)

Than will be all elements Array1 equal 100 (both array will be equal)

I understand me? Sorry my bad english :-(

 
endy5:

but it will do filling all element array retArr on value 100 and array Array1 will be zero. I want bring retArr from function to Array1 - as return value from function return( ???)

Than will be all elements Array1 equal 100 (both array will be equal)

I understand me? Sorry my bad english :-(

Array retArr IS array Array1 . . . Array1 is passed by reference. Array1 will be initialised with 100 . . . array retArr doesn't exist . . it is just a reference to Array1.

Try this as a Script and see for yourself . . .

double Array1[500];

int start()
  {
   functionABC(Array1);
   Print("Array1 element215: ", Array1[214], " element 345: ", Array1[344]);
   return(0);
  }


void functionABC(double& retArr)
   {
   ArrayInitialize(retArr,100);
   }

 

repair: functionABC(double& retArr[500])

I tried it and I must say that you had right! It is new info for me... Thank you very mutch!!!!

Reason: