alladir: somehow _lread sets both strings to the characters read from the file!
- Looks like File Operations via WinAPI - MQL4 Articles
char1 = char;
Apparently MT4 uses COW semantics for strings. That results in one buffer with two names.- Don't call GetLastError, unless you have an error
if(result<0){ Alert("Error placing the pointer" ); // Capture GLE here. return (-1); } error = GetLastError(); // No error (result positive) if(error!=0) // GLE may be ANYTHING, meaningless. { Alert("error during open before array init:",error); } error = GetLastError(); // This will ALWAYS return zero. if(error!=0) { Alert("error during open:",error); } return(handle); }
Thanks, yes I stole most of the code from that article.
Any ideas on the second problem...? Why char1="xxxxxx" works, but char1=StringSubStr("xxxxxxxxxx",0,6) doesn't work.. I feel they should be identical so there's some things I'm just not understanding.
As for the GetLastErrors, I hoped that with with no error's, it's not called, so no problem. I make so many small silly mistakes that it's useful to help me understand and locate problems until the code is finished and I can delete them. Am I doing this the wrong way?
edit:
Well I still don't understand the problem but I'll set the number of x's with a switch.. should work
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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 all, I have a strange result with _lread in winAPI:
I set a string (char) as 50 x's, then I set another string (char1) as the value of char, then I use char1 with _lread.. somehow _lread sets both strings to the characters read from the file!
gives this result:
Actually, this is not my main problem but it might be related.
This is my main problem: I need to make the number of characters read from file to be variable, so when using char1 with _lread, I tried something like this:
it gives:
result = 6 (good! it read 6 characters)
char1 = xxxxxx (not good, it left them as x's)
I hope real programers will know what's going on here..? :/