BTW, you don't actually need to do a dummy web request to work round the MT4 bug.
Any long string concatenation seems to "seed" MT4's memory handling and make the problem then go away. For example, you can call a dummy string concatenation such as https://www.mql5.com/en/forum/149360, and after that you should be able to read web data without needing to ignore the first result.
BTW, you don't actually need to do a dummy web request to work round the MT4 bug.
Any long string concatenation seems to "seed" MT4's memory handling and make the problem then go away. For example, you can call a dummy string concatenation such as https://www.mql5.com/en/forum/149360, and after that you should be able to read web data without needing to ignore the first result.
Oh great, it works with this hotfix on start. thanks again. Here is the fix:
#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 InternetReadFile(int, uchar & arr[], int, int & arr[]);
int InternetCloseHandle(int);
#import
//-----------------------------------------------------------------------------------------------------// Reads the specified URL and returns the server's response. Return value is // a blank string if an error occurs //-----------------------------------------------------------------------------------------------------string urlRead(string Url, bool PrintDebuggingMessages = false)
{
string strData = "";
bool bSuccess = false;
// Get an internet handleint hInternet = InternetOpenW("mt4", 0/* 0 = INTERNET_OPEN_TYPE_PRECONFIG */, NULL, NULL, 0);
if (hInternet == 0) {
if (PrintDebuggingMessages) Print("InternetOpenW() failed");
} else {
// Get a URL handleint hInternetUrl = InternetOpenUrlW(hInternet, Url, NULL, 0, 0, 0);
if (hInternetUrl == 0) {
if (PrintDebuggingMessages) Print("InternetOpenUrlW() failed");
} else {
if (PrintDebuggingMessages) Print("Okay: url handle: ", hInternetUrl);
// We potentially (in fact, usually) get the response in multiple chunks// Keep calling InternetReadFile() until it fails, or until// it says that the read is completebool bKeepReading = true;
while (bKeepReading) {
int szRead[1];
uchar arrReceive[];
ArrayResize(arrReceive, READURL_BUFFER_SIZE + 1);
int success = InternetReadFile(hInternetUrl, arrReceive, READURL_BUFFER_SIZE, szRead);
if (success == 0) {
if (PrintDebuggingMessages) Print("InternetReadFile() failed");
bKeepReading = false;
} else {
// InternetReadFile() has succeeded, but we may be at the end of the data if (szRead[0] == 0) {
if (PrintDebuggingMessages) Print("Reached end of data");
bKeepReading = false;
bSuccess = true;
} else {
// Convert the data from Ansi to Unicode using the built-in MT4 functionstring strThisRead = CharArrayToString(arrReceive, 0, szRead[0], CP_UTF8);
strData = StringConcatenate(strData, strThisRead); // <-- PROBLEM HERE ON FIRST USE ONLY IN EACH MT4 SESSION
}
}
}
InternetCloseHandle(hInternetUrl);
}
InternetCloseHandle(hInternet);
}
return (strData);
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
thanks so much gchrmt4. it works fine and the string/space/"F" memory issue has disappeared, here his a sample call:
Usually it works with second call. If not this is a server error out of of MT4 scope problem.
THANKS AGAIN buddy.
THANKS AGAIN buddy.
BTW, you don't actually need to do a dummy web request to work round the MT4 bug.
Any long string concatenation seems to "seed" MT4's memory handling and make the problem then go away. For example, you can call a dummy string concatenation such as https://www.mql5.com/en/forum/149360, and after that you should be able to read web data without needing to ignore the first result.
BTW, you don't actually need to do a dummy web request to work round the MT4 bug.
Any long string concatenation seems to "seed" MT4's memory handling and make the problem then go away. For example, you can call a dummy string concatenation such as https://www.mql5.com/en/forum/149360, and after that you should be able to read web data without needing to ignore the first result.
Oh great, it works with this hotfix on start. thanks again. Here is the fix: