Download MetaTrader 5

return expressions are not allowed on a global basis

To add comments, please log in or register
theheiko
20
theheiko  

Hi,

since the latest upgrade to build 600 I am getting the "return - expressions are not allowed on a global basis" error. Any idea why that happens?

int start()
  {
           
         write_data();
         
      }
   
   return;
  
  
Ex Ovo Omnia
3188
Ex Ovo Omnia  
theHeiko:

Hi,

since the latest upgrade to build 600 I am getting the "return - expressions are not allowed on a global basis" error. Any idea why that happens?


The function declares int type, while you return void.

return 0; would fix it.

theheiko
20
theheiko  
Ovo:


The function declares int type, while you return void.

return 0; would fix it.


in brackets? return(0) returns the same error unfortunately

int start()
  {
  
         
         write_data();
         
      }
   
return(0);
  
ydrol
593
ydrol  
Error means return must be inside the function not outside
Ex Ovo Omnia
3188
Ex Ovo Omnia  
ydrol:
Error means return must be inside the function not outside

Indeed.
theheiko
20
theheiko  

Thanks for your help

theheiko
20
theheiko  

Hi Guys,

still struggling with this. Here is the complete code. What exactly do I need to change? Your help is very much appreciated

extern int size = 50;

//----
void write_data()
   {
   
//----
   if (size==0) return;
   int handle=FileOpen("DATA_TEST.csv",FILE_WRITE|FILE_CSV,',');
   if (handle<0) return;
   FileWrite(handle," ,EURUSD, EURUSD, EURUSD, EURUSD");
   FileWrite(handle,"DATE,OPEN, HIGH, LOW, CLOSE");
   
   for (int i=0;i<=size;i++)
      {
      FileWrite(handle,TimeToStr(iTime("EURUSD",PERIOD_D1,i),TIME_DATE),
     iOpen("EURUSD",PERIOD_D1,i),
     iHigh("EURUSD",PERIOD_D1,i), 
     iLow("EURUSD",PERIOD_D1,i), 
     iClose("EURUSD",PERIOD_D1,i)); 
     
      }
   FileClose(handle); 
   
      }     

   return;
   
//+------------------------------------------------------------------+
//|                                   |
//+------------------------------------------------------------------+
int start()
  {
  
         
         write_data();
         
      }
   
return(0);
  
//+------------------------------------------------------------------+ 
Simon Gniadkowski
Moderator
18003
Simon Gniadkowski  
theHeiko:

Hi Guys,

still struggling with this. Here is the complete code. What exactly do I need to change? Your help is very much appreciated


You have already been told, is it not clear ?

ydrol:
Error means return must be inside the function not outside
theheiko
20
theheiko  
obviously not. otherwise I wouldn't have posted this
Simon Gniadkowski
Moderator
18003
Simon Gniadkowski  
theHeiko:
obviously not. otherwise I wouldn't have posted this

OK . . .

int start()
   {
   write_data();

   return(0);         
   }
   

the { } braces show the extent of the function, the return must be inside the function.

theheiko
20
theheiko  
Thanks Raptor. That makes it clearer
12
To add comments, please log in or register