'.' - semicolon expected - MetaEditor errors

 
I have not done any code for a while, but I restarted my EA's and was going to work on some ideas.

The EA's did not have errors in the past but now they do.

All of the Meta Editor error seem to be from the 3 || 5 digit adjustment code and are as follows:

'.' - semicolon expected    Daily Rat.mq4    16    15
'pips' - struct or class type expected    Daily Rat.mq4    33    58
'pips' - struct or class type expected    Daily Rat.mq4    37    58


3 || 5 digit adjustment code shown below
Line 16 is (int  Digits.pips;) and says it expects a colon where the (.) dot.pips is located

//++++ These are adjusted for 5 digit brokers.

int     pips2points;    // slippage  3 pips    3=points    30=points
double  pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)

    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
    
// my crappy attempt to create a function

    
    
    
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+

int init()
  {
   if (Digits == 5 || Digits == 3)
   {    // Adjust for five (5) digit brokers.
      pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
   } 
   else 
    {    
      pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; 
    }
    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl


//----
   
//----
   return(0);
  }


A few other errors that did not exist in the past indicate:
function must return a value    Daily Rat.mq4    70    30
function must return a value    Daily Rat.mq4    108    34

The code lines producing this are:

   static datetime Time0Last;
   if (Time0Last == Time[0]) return;  

None of these produced errors in the past, so I'm not really sure how to diagnose this unless there is some obsolete lines or something.

What changed ?

Please advise

 
You cant use dots in variable names anymore.
 
Ok thanks, this must have occurred with Metatrader 4 updates.
I also noticed creating EA's renamed init  to Oninit and denit to void Deinit
Also another line for void Ontick

So looks like I have some reading to do before I resume my code learning.

What about return; ?
https://docs.mql4.com/basis/operators/return
This never produced errors before either

What is the different between these:
I mean the return; action is what is wanted to return it back to the top of the code not to continue on to the next statements.
Isn't the current return; simply returning out of the if statement and going back to the top of that function again ? Looping over and over Until we get a condition where Time0Last is no longer the same as Time[0] ?

static datetime Time0Last;
   if (Time0Last == Time[0]){} //return;

static datetime Time0Last;
   if (Time0Last == Time[0]) return;

static datetime Time0Last;
   if (Time0Last == Time[0]) return();

static datetime Time0Last;
   if (Time0Last == Time[0]){} //return(NULL);

I'm confused about this now that it's not working and reading the reference library
Please advise thanks
 

Agent86:

 function must return a value


well, are you returning a value? what kind of value you have to return? how is your function defined? 

these are C language basics. take a C/C++ book.

MQ took a great liberty in implementing a MQL as C++ like language.
Now they have changed, and MQL has become almost a strict C++ implementation.

return(value); 
Also check for definition of NULL. NULL is not a value.
 
Agent86:

What about return; ?
https://docs.mql4.com/basis/operators/return
This never produced errors before either

What is the different between these:
I mean the return; action is what is wanted to return it back to the top of the code not to continue on to the next statements.
Isn't the current return; simply returning out of the if statement and going back to the top of that function again ? Looping over and over Until we get a condition where Time0Last is no longer the same as Time[0] ?


I'm confused about this now that it's not working and reading the reference library
Please advise thanks

  return ends the function

 you must return a value of the correct type

for example if the function is;

int  myfunction() you must return an integer,  return(0);

if it is a void type function

void myfunction() you must not return a value, you just use return;

 
Well thanks all,

I don't need a value so return(NULL); should be good

or even return(0)
or even {} which is explicitly a return; of NO value according to the documents
All of the above produces NO errors.

So it would seem return; is only valid now where void myfunction() is used otherwise requires a value or NON value such as (NULL)

As it was working previously and did not produce meta editor errors, I assume it was treated as {} explicitly no value returned right ?

Thanks all

 
Agent86:
Well thanks all,

I don't need a value so return(NULL); should be good

or even return(0)
or even {} which is explicitly a return; of NO value according to the documents
All of the above produces NO errors.

So it would seem return; is only valid now where void myfunction() is used otherwise requires a value or NON value such as (NULL)

As it was working previously and did not produce meta editor errors, I assume it was treated as {} explicitly no value returned right ?

Thanks all



  void myfunction() does not require a return at all it will end by itself when it is finished, if you want to exit the function early use return;

  example

 void myfunction(datetime last_time)
 {
  if(Time[0] <= last_time) return;  //exit early

  else Print("New Bar");
 }
Reason: