Returning arrays in Functions

 

Hi, I came accross the following problem:


In my indicator I use two different libraries and now I want to exchange data between those libraries. I have my indicator main file, and then there are libraries A and B.

Library A makes some calculations and saves the result in a global array of integers. Now I want to get this array and pass it to library B to make some further calculations.


How can I get this array from library A and access it in my indicator main file? I tried the following:


In library A there's the array called


int results[];

I added this funtion to library A and imported it into my main indicator file:


int[] get_results()
{
   return (results);
}

But this didn't work. Then I tried the following:


void get_results (int& save[])
{
   ArrayResize(save,ArraySize(results));
   ArrayCopy(results,save);
}

So in my main indicator file, I call it:


   int tmp[];
   get_pnf(tmp);


But this doesn't work either. Can someone point me into the right direction? Have searched the forums, docs, tutorial, Google... with no viable results.


Thank you!

 
adamp:

Hi, I came accross the following problem:


In my indicator I use two different libraries and now I want to exchange data between those libraries. I have my indicator main file, and then there are libraries A and B.

Library A makes some calculations and saves the result in a global array of integers. Now I want to get this array and pass it to library B to make some further calculations.


How can I get this array from library A and access it in my indicator main file? I tried the following:


In library A there's the array called



I added this funtion to library A and imported it into my main indicator file:



But this didn't work. Then I tried the following:


So in my main indicator file, I call it:



But this doesn't work either. Can someone point me into the right direction? Have searched the forums, docs, tutorial, Google... with no viable results.


Thank you!

Problem solved. The last piece of code is working :)

I simply need some sleep and made some stupid mistake... sorry:

Reason: