Download MetaTrader 5

cannot convert type string to bool

To add comments, please log in or register
gangsta1
1259
gangsta1  
This was fine before new mt4 builds but is throwing up "cannot convert type string to bool" when I try to compile now, any ideas?

if((bool)response.getAttribute("error"))
honest_knave
Moderator
2326
honest_knave  
gangsta1:
This was fine before new mt4 builds but is throwing up "cannot convert type string to bool" when I try to compile now, any ideas?

if((bool)response.getAttribute("error"))
Check point #5 here 
Fernando Carreiro
2876
Fernando Carreiro  
honest_knave: Check point #5 here 
That is in reference to MT5, but the OP is reporting the issue on MT4. If that is indeed the case (as I have not tested it myself), then development on MT4 is not just bug fixes, but still has some active development taking place. However, this may not be intentional, but just a side effect of internally shared or common code between the versions.
honest_knave
Moderator
2326
honest_knave  
Fernando Carreiro:
That is in reference to MT5, but the OP is reporting the issue on MT4. If that is indeed the case (as I have not tested it myself), then development on MT4 is not just bug fixes, but still has some active developed taking place. However, this may not be intentional, but just a side effect of internally shared or common code between the versions.
Yes, it is the same behaviour in MQL4. I surmize this is because it is a common compiler.
Fernando Carreiro
2876
Fernando Carreiro  
honest_knave: Yes, it is the same behaviour in MQL4. I surmize this is because it is a common compiler.
True, I forgot that the Compiler/Editor is common. Guess I am needed some "zzz's" and not thinking straight!
honest_knave
Moderator
2326
honest_knave  
Fernando Carreiro:
True, I forgot that the Compiler/Editor is common. Guess I am needed some "zzz's" and not thinking straight!
I know that feeling! 
Carl Schreiber
7292
Carl Schreiber  
honest_knave:
Yes, it is the same behaviour in MQL4. I surmize this is because it is a common compiler.
I doubt that as it is my experience that mql5.-compiler cannot compile e.g. DoubleToStr() /* the old mt4 function */ while the mql4 compiler already compiles both functions DoubleToStr() and DoubleToString().
honest_knave
Moderator
2326
honest_knave  
Carl Schreiber:
I doubt that as it is my experience that mql5.-compiler cannot compile e.g. DoubleToStr() /* the old mt4 function */ while the mql4 compiler already compiles both functions DoubleToStr() and DoubleToString().

Now there is only one version of MetaEditor, I'm surmizing (again) that MetaQuotes aren't going to bother to make the compiler behave differently between MQL4 and MQL5 with these sort of changes. They certainly haven't with this "feature" i.e. disabling the support for casting string types to bools.

Legacy items like DoubleToStr() and TimeToStr() had to be explicitly catered for in the past, but why would they bother differentiating now?

Fernando Carreiro
2876
Fernando Carreiro  
Carl Schreiber: I doubt that as it is my experience that mql5.-compiler cannot compile e.g. DoubleToStr() /* the old mt4 function */ while the mql4 compiler already compiles both functions DoubleToStr() and DoubleToString().
It is a fact that it is the same compiler, not an opinion. The same compiler can compile both MQL4 and MQL5 code, but obviously it has two modes of operation, but that does not mean that it does not share a common base code.

It would not make any sense for them to keep two separate "base" code sections for each one, if they use a single compiler. If they had, they would have done separate compilers.
Alain Verleyen
Moderator
33334
Alain Verleyen  
gangsta1:
This was fine before new mt4 builds but is throwing up "cannot convert type string to bool" when I try to compile now, any ideas?

if((bool)response.getAttribute("error"))
         if(StringCompare(response.getAttribute("error"),"true",false)==0)
gangsta1
1259
gangsta1  
Alain Verleyen:
         if(StringCompare(response.getAttribute("error"),"true",false)==0)
Thank you very much Alain! Solved the error perfectly. :-)
12
To add comments, please log in or register