return expressions are not allowed on a global basis

 

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;
  
  
 
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.

 
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);
  
 
Error means return must be inside the function not outside
 
ydrol:
Error means return must be inside the function not outside

Indeed.
 

Thanks for your help

 

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);
  
//+------------------------------------------------------------------+ 
 
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
 
obviously not. otherwise I wouldn't have posted this
 
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.

 
Thanks Raptor. That makes it clearer
Reason: