Assinging Variable References and returning them from functions in MQL4

 
datetime DayOneArray[] = {D'0000.00.00 00:00:00',D'0000.00.00 00:00:00'};  // no valid time identified on this day
datetime DayTwoArray[] = {D'0000.00.00 05:45:00',D'0000.00.00 15:00:00'};
Etc.
So then we have function:
void DoSomethingOnDay(int day)
{
   datetime TimeArray[]; // cannot define as pointer or datetime &TimeArray[];
   GetDayArray(day, TimeArray);
   //work with TimeArray
   if (TimeIsValid(TimeArray))
   {
   }
}
void GetDayArray(int day, datetime &timeArray[])  // return datetime &timeArray[], but am using global to work around inability to return such a thing and not passing the array reference.
{
   switch (day)
   {
      case 1:
      {
         timeArray = DayOneArray;
      }
      // etc.
   }
}
Just a question on if there is a way to assign an array to a reference variable (Pointer) in MQL 4 language.  I seem to always be working around this by sizing and copying array elements.
Example segments for an EA that does different things at different times on different days, so I have these time arrays detailing at what times an activity may be valid:

Just wondering if anyone has a good solution in MQL4 / am I missing something to make this work easily in the language.
 
LukeB:
Just a question on if there is a way to assign an array to a reference variable (Pointer) in MQL 4 language.  I seem to always be working around this by sizing and copying array elements.
Example segments for an EA that does different things at different times on different days, so I have these time arrays detailing at what times an activity may be valid:

Just wondering if anyone has a good solution in MQL4 / am I missing something to make this work easily in the language.
Not sure I'm 100% following what you are trying to do . . .  but couldn't you just use a 2D array where the first dimension was the day number ?
 
RaptorUK:
Not sure I'm 100% following what you are trying to do . . .  but couldn't you just use a 2D array where the first dimension was the day number ?


2D array is a potential solution for this specific example. But, you run into problems with the data types needing to be different in the different dimensions (int versus date-time), and the use of ArraySize() to step through elements in the array is less clear.    You can send a reference to a function, I just haven't found a way to send one back to the caller.  But, there is always a way.
 
LukeB: 2D array is a good solution - I just haven't found a way to send one back to the caller.
double ar[][2]; int nAr = Function(ar);
:
int Function(double& ar[][2]){ // Pass by reference
   ArrayResize(ar, 3)
   ar[2][1] = 0;
   return(3);
 
LukeB:

2D array is a potential solution for this specific example. But, you run into problems with the data types needing to be different in the different dimensions (int versus date-time), and the use of ArraySize() to step through elements in the array is less clear.    You can send a reference to a function, I just haven't found a way to send one back to the caller.  But, there is always a way.

Why do you need to ?  just copy the correct array to a "CorrectDayArray"  and work from that,  would that solve your issue ?
 
RaptorUK:
Why do you need to ?  just copy the correct array to a "CorrectDayArray"  and work from that,  would that solve your issue ?


That works - as mentioned in the opening post: "I seem to always be working around this by sizing and copying array elements.".
Reason: