very strange behaviour of the compiler ??

 

Hi

I coded a function in a script ( with #property strict ) and it compiles and works perfectly!

Now I pasted just this function in my EA which compiles with no error before the pasting(!) it is 'strict' as well and there is so far no call of this function in that EA and now I get a lot errors:

double strange(string sym, int tFr, int per, int i, double ma = -1.0 ){
        if ( ma < 0.0 ) ma = iMA(sym, tFr, per, 0, MODE_SMA, PRICE_TYPICAL, i);
        //...
        return(ma);
}

This are the errors:


Again: there is NO problem in the script??

If I comment-out the first line: if (ma < 0.0).. no problem??

I even tried to place this function in the EA not at the end but some where else and put the {} around ma=.. - same errors :(

Anybody with a hint?

Thanks in advance and have a nice Sunday!

Gooly

 

That is strange!

I pasted it into an EA, also property script and it compiled just fine (Build 966 )

Which is line 1000 in your code? 

 
gooly:

Anybody with a hint?

Very strange. Clipboard problem? You could potentially get something like this if what appears to be a normal space or tab (0x09, 0x20 etc) has somehow got pasted in as a Unicode character such U+2003. Similarly, < could perhaps become something like U+02C2. EDIT: or the copy-and-paste has created some unprintable characters which the text editor is not rendering.

Try looking at the .mq4 file in a hex editor. Would also be interesting to know if either of the following makes a difference:

* Save .mq4 file; close MetaEditor; re-open MetaEditor; try compiling again

* Paste the block of code to Notepad, and then re-select it in Notepad and re-copy it to the clipboard from there. 

 
gooly: Anybody with a hint?
hides local ... at line 999
Look (or post) the code above that. That is where the problem likely is. Probably pasted inside the previous function..
 

Hi,

thanks for your answers but the solution is too easy but I still can't understand or explain it.

I simply has to replace ma by avg. No idea,why this matters. Anyway this compiles with no error:

double strange(string sym, int tFr, int per, int i, double avg = -1.0 ){
        if ( avg < 0.0 ) avg = iMA(sym, tFr, per, 0, MODE_SMA, PRICE_TYPICAL, i);
        //...
        return(avg);
}


PS I found the reason. I defined an enum ma {..};

And this causes the trouble with the misleading Error messages. I'll ask the service desk to improve their messages..

Reason: