Alert (StringFind(s,"\n",0)," ",StringReplace(s,"\n"," ") );
return: StringFind() --> -1
StringReplace() --> 3
I'd guess the following:
hmmm I wrote Alert code to two rows:
Alert (StringFind(s,"\n",0)); // return: 0
Alert(StringReplace(s,"\n"," ") ); // return: 3
strange behavior MT4 (for me)
The order that parameters are processed is not defined. Therefor your original alert did the replace first, creating a new s. Then the find proceeded, on the no longer existing string.
See int b=(a++)*3; // invalid expression
Once again, the MQL manual has a rather strange approach in expressing "notions". The expression int b=(a++)*3 is not invalid, as if invalid means that it will generate a compilation error.
All in all , it will work as described in that very page
" The prefix increment (++i) and decrement (--k) are applied to the variable right before this variable is used in an expression.
Post-increment (a++) and post-decrement (k--) are applied to the variable right after this variable is used in an expression"
As an example, the following part is working as expected
int a=5; int b=(a++)*5; int c=(++a)*5;
Alert(a," ",b," ",c);
Regarding OP's question, it looks like there is a "bug". I put double quotes on it because it seems that the functions are regarded as "imported"; as such they are, as have been said, evaluated form right to left. Still, please pay attention to the manual saying regarding StringFind()
Returns position number
in a string, from which the searched substring starts, or -1, if the substring
is not found"
As such, it is legitimate to return 0
EDIT at the manual, at page Functions > Function call, we can read
" The order of expressions calculation and the order of values loading are not guaranteed "
I guess that statement is above and beyond any rules regarding precedence rules hehe
To add comments, please log in or register