If the first integer read is not the search parameter, you return false instead of continuing to search.
William Roeder #:
If the first integer read is not the search parameter, you return false instead of continuing to search.
If the first integer read is not the search parameter, you return false instead of continuing to search.
But i've put the search parameter - "ticket" number at the begin of file and the line also.
I just modify the code a little bit like below:
bool CheckOrderExist(string _filename,int _ticket) { bool orderexist=false; int handle = FileOpen(_filename,FILE_COMMON|FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_READ|FILE_CSV); if(handle!=INVALID_HANDLE) { while(!FileIsEnding(handle)) { int a = FileReadInteger(handle); if(_ticket==a) { orderexist=true; FileClose(handle); return orderexist; } else orderexist=false; printf(a); // >>>Check the value of a but nothing break; } } else printf("Can not read the file for checking. Error: ",GetLastError()); return orderexist; }
But the result the same: ***
What part of “continuing to search” was unclear to you?
What part of “If the first integer read is not the search parameter, you return false instead of continuing to search” is unclear to you? Run in the debugger and find out.
bool CheckOrderExist(string _filename,int _ticket) { bool orderexist=false; int handle = FileOpen(_filename,FILE_COMMON|FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_READ|FILE_CSV); if(handle!=INVALID_HANDLE) { while(!FileIsEnding(handle)) { int a = FileReadInteger(handle); if(_ticket==a) { orderexist=true; FileClose(handle); return orderexist; } } } else printf("Can not read the file for checking. Error: ",GetLastError()); FileClose(handle); return orderexist; }
William Roeder #:
What part of “If the first integer read is not the search parameter, you return false instead of continuing to search” is unclear to you? Run in the debugger and find out.
What part of “If the first integer read is not the search parameter, you return false instead of continuing to search” is unclear to you? Run in the debugger and find out.
Yes bro. I run in debug mode a saw that, the function is can not get the value by the FileReadInteger() so can not meet the condition of If(). But i down know why.
Can you help me this bro?

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 Everyone!
I'm trying to make my EA checking order exist or not by order's ticket as the code below:
Result: No error in compiling, no error by GetLastError(), and no result as i want. Its seems to be loop or stuck somewhere i dont know, it makes MT4 working slow nearly crashed.
Please anyone tell me what wrong i did.
Thank you so much!
p/s: The orders file attached.