'.' - semicolon expected - MetaEditor errors
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.
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;
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
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"); }
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
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:
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