alladir:
Mostly it will be personal preference or just what has become habit for people, but there is also a small consideration to covering undocumented possibilities or future changes . . . if MetaQuotes change the return value in the case of an error to -999 the first 2 options would work, the third would not.
Hi! I normally search for answers instead of asking (I've learned so much from this forum! Thanks to everyone!!!) but... I can't figure this one out.
Calling FileOpen returns the handle or "-1" if there was an error.
So why do I always see error checking done with:
Ok, great, thanks.
Also well done on all your hard work on these forums.
I don't reply to every thread that helps but you've helped me countless times already!
alladir:
You are most welcome
Ok, great, thanks.
Also well done on all your hard work on these forums.
I don't reply to every thread that helps but you've helped me countless times already!
alladir: So why do I always see error checking done with:
if(handle<1);
or
if(handle<0);
Why do people avoid using?
if(handle==-1);
- The first is wrong, a handle of zero COULD be a good value, just as a ticket number zero COULD be a good one.
- Currently -1 on an error. If it was ever modified it could return -1 for one type and -2 for another type, etc. The test would still work.
- Personal preferences and/or less typing (< vs ==)
- Doubles rarely compare equal so testing for equality is usually wrong. So the habit transfers to this case.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi! I normally search for answers instead of asking (I've learned so much from this forum! Thanks to everyone!!!) but... I can't figure this one out.
Calling FileOpen returns the handle or "-1" if there was an error.
So why do I always see error checking done with:
or
Why do people avoid using?
Thanks in advance for any tips