Download MetaTrader 5

[FIXED] Build 604 - major issue with a string containing a single space " " and wininet.dll unicode W import

To add comments, please log in or register
David Saulnier
405
David Saulnier  

Don't know if someone got this:

Alert("aaaaa "+Symbol()+" bbbbb "+" "+" ddddd");

" " space is displayed by a "F" instead of the space itself.

Same issue when using string concatenation and a single space between quote..

but in the above case with "Alert" if the call to Symbol() is omit the space is well displayed...

Any fix ?

Keith Watford
Moderator
10652
Keith Watford  
I put your line of code in a script and the alert showed with the spaces, no F's. (Build 604)
Alain Verleyen
Moderator
33290
Alain Verleyen  
DavidS777:

Don't know if someone got this:

" " space is displayed by a "F" instead of the space itself.

Same issue when using string concatenation and a single space between quote..

but in the above case with "Alert" if the call to Symbol() is omit the space is well displayed...

Any fix ?


Hello,

Can you post a screenshot to show the problem ? Which Windows version are you using ?

David Saulnier
405
David Saulnier  

!!! Well I just found the problem but I appreciate any return.

If I remove this part and all related functions calls, it works again for the space

#import  "Wininet.dll"

   int InternetAttemptConnect(int x);
   int InternetOpenW(string, int, string, string, int);
   int InternetConnectW(int, string, int, string, string, int, int, int);
   int HttpOpenRequestW(int, string, string, int, string, int, string, int);
   int InternetOpenUrlW(int, string, string, int, int, int);
   int InternetReadFile(int, string, int, int& OneInt[]);
   int InternetCloseHandle(int);
#import

When using windows Unicode "W" functions there is probably a confilct with string system of MQL4 between DLL or something...

Using "A" ansi calls is not possible because InternetOpenUrlA is no working in build 604.


Please try to add following import to the sample you will see the "F" instead of " " (space)

gchrmt4
356
gchrmt4  
DavidS777:

!!! Well I just found the problem but I appreciate any return.

What happens if you remove only the use of InternetReadFile and leave all the other WinInet calls?
David Saulnier
405
David Saulnier  
gchrmt4:
What happens if you remove only the use of InternetReadFile and leave all the other WinInet calls?

Yes if commenting InternetReadFile it works!

What can I use instead ?! I'm not sure if there is a InternetReadFileW and if this is interesting as I'm reading a mix of text and binary data.

gchrmt4
356
gchrmt4  
DavidS777:

Yes if commenting InternetReadFile it works!

What can I use instead ?! I'm not sure if there is a InternetReadFileW and if this is interesting as I'm reading a mix of text and binary data.

Thought so. I am amazed that this use of InternetReadFile is working at all. It is collecting the Ansi data which the server has responded with and, somewhere along the line, it is somehow getting converted to Unicode. This implicit process is probably corrupting MT4's memory, leading to the strange effects elsewhere.

For alternative ways of using InternetReadFile in the new version of MQL4, see topics such as https://www.mql5.com/en/forum/149321 and https://www.mql5.com/en/forum/149360

David Saulnier
405
David Saulnier  
Thank you for your reply. I'll investigate the topics you mention and let you know if issue can be solved this way. Cheers.
David Saulnier
405
David Saulnier  

Unfortunately I'm using the "grabweb" function as explain in the topic. Those guys may not have notice the memory failure problem on strings at the moment.

I've no other choice of rewriting my own DLL encapuslating Internet functions. Or another concept like SQL access do my remote date. I'll keep you post if I've something fixed to share.

gchrmt4
356
gchrmt4  
DavidS777:

Unfortunately I'm using the "grabweb" function as explain in the topic. Those guys may not have notice the memory failure problem on strings at the moment.

I've no other choice of rewriting my own DLL encapuslating Internet functions. Or another concept like SQL access do my remote date. I'll keep you post if I've something fixed to share.

AFAIK, the code at https://www.mql5.com/en/forum/149360 works, except for a problem on its very first use in each MT4 session which appears to be caused by a fundamental problem in MT4 which applies to any type of concatenation of long strings (https://www.mql5.com/en/forum/149360).

You can get round that problem by doing a dummy call to ReadUrl() on the first time that you want to use it (https://www.mql5.com/en/forum/149360). In addition, the problem should only affect you if you are reading more than about 1KB of data from the web server.

David Saulnier
405
David Saulnier  
Once again thanks for your help, I'll try. And yes I'm reading 9kb of data.
12
To add comments, please log in or register