Error: " '}'-not all control paths return a value " (NEED HELP)

 

Hello everyone, 

I'm trying to add a simple account licensing restriction for my EA. After searching around the forum for a fix I couldn't seem to find what I'm missing here....

Error warning is marked on the last curly bracket saying:  '}'-not all control paths return a value

Any help is greatly appreciated. 

int start()
{
   int hard_accnt = 123456; //<-- type the user account here before compiling
   int accnt = AccountNumber();
   if (accnt != hard_accnt)
      {
         Alert ("Your Account is Not Registered (" + DoubleToStr(accnt,0) + ") Please contact Admin");
         return(0);
      }
    string batas="2050.12.12 00:00";
    int tt=StrToTime(batas);
    if(TimeCurrent()>tt)
      {
       Alert("License Expired Please contact Admin"); 
       return(0);
      }
}
 
Add return(0); before the closing } of start function
 
Nikolay Georgiev:
Add return(0); before the closing } of start function

Hi Nikolay

I did it like so, don't know if this is what you meant but now I get a '}' - Semicolon expected warning

int start()
{
   int hard_accnt = 123456; //<-- type the user account here before compiling
   int accnt = AccountNumber();
   if (accnt != hard_accnt)
      {
         Alert ("Your Account is Not Registered (" + DoubleToStr(accnt,0) + ") Please contact Admin");
         return(0);
      }
    string batas="2050.12.12 00:00";
    int tt=StrToTime(batas);
    if(TimeCurrent()>tt)
      {
       Alert("License Expired Please contact Admin"); 
       return(0);
      }
return(0) 
}
 
Josh Farlow:

Hi Nikolay

I did it like so, don't know if this is what you meant but now I get a '}' - Semicolon expected warning

you have to learn the syntax first

after return(0) you need to place ; 

return(0);

like this

 
Khuman Bakhramirad:

you have to learn the syntax first

after return(0) you need to place ; 

like this

Hello Khuman, 

After some trial an error I managed to figure that out and finally could compile without a problem. 

It was exactly as you said.

I appreciate your help. 

 
Josh Farlow:

Topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I have moved your topic to the MQL4 and Metatrader 4 section.