"extern" is now "input". init() is now OnInit(). start() is now OnTick(). deinit() is now OnDeinit();
trader88888: i can't find a "start" anywhere else in the code so not sure how it's already define. I was hoping that someone might be able to change it around and paste the full code again so I can just copy and paste it and try to compile again?
- Have you looked in your
#include "..\libraries\RemoteQueryLib.mq4"
- We can't compile it unless you provide all the include files.
- JDeel:The old functions are still viable.
"extern" is now "input". init() is now OnInit(). start() is now OnTick(). deinit() is now OnDeinit();
WHRoeder:
- Have you looked in your
- We can't compile it unless you provide all the include files.
- JDeel:The old functions are still viable.
"extern" is now "input". init() is now OnInit(). start() is now OnTick(). deinit() is now OnDeinit();
WHRoeder, thank you, here is the file you mentioned for the includes. I believe the others are standard in mt4 except for this one: (..\libraries\RemoteQueryLib.mq4")
//+------------------------------------------------------------------+ //| RemoteQueryLib.mq4 | //+------------------------------------------------------------------+ #property copyright "me" #property link "me@me.com" #define RQL_VERSION 1.02 // Version of the RemoteQuery library. #define RQL_MAX_PARAMS 16 // Maximum number of parameters to retrieve. // Increase this number if you expect more parameters. #define RQL_KEY_VALUE_PAIR_TAG "DATA" // The XML node that encapsulates the key-value pair. #define RQL_KEY_TAG "PARAM" // The tag the encapsulates the parameter name. #define RQL_VALUE_TAG "VALUE" // The tag that encapsulates the parameter value. #define RQL_ERROR_TAG "ERROR" // The error tag. #define RQL_QUOTES_MAX_SYMBOLS 32 // Maximum symbols that can be published. Increase if you plan to publish more. #define RQL_QUOTES_SUCCESS_TAG "SUCCESS" // Quotes update success tag. #include <stderror.mqh> #include <stdlib.mqh> #import "wininet.dll" int InternetAttemptConnect(int a0); int InternetOpenA(string a0, int a1, string a2, string a3, int a4); int InternetOpenUrlA(int a0, string a1, string a2, int a3, int a4, int a5); int InternetReadFile(int a0, int& a1[], int a2, int& a3[]); int InternetCloseHandle(int a0); #import //////////////////////////////////////////////////////////////////////////////// // Function : queryParams // // Inputs : sUrl - The HTTP URL (can be PHP, HTML, etc). // Output : nParamCount - The number of parameters found on the URL // sParams[] - Array of the parameter names. // sValues[] - Array of the parameter values. // sError - The error message if any error occurred // Result : TRUE if URL was successfully accessed and parameters queried. // FALSE if there was an error or no parameters were queried. // The format of the URL data is // <dbdata> // <data><param>X1</param><value>44.25</value></data> // <data><param>X2</param><value>12.15</value></data> // </dbdata> //////////////////////////////////////////////////////////////////////////////// bool queryParams(string sUrl, int &nParamCount, string &sParams[], string &sValues[], string &sError) { bool bSuccess = false; // Return value. nParamCount = 0; sError = ""; // Initialize. if( StringLen(sUrl) <= 3 ) // The URL should be atleast 3 characters. { sError = "Invalid URL. The URL should be atleast 3 characters."; return (bSuccess); } string sData = ""; int nKeyBeginIndex = 0; if( getUrlData(sUrl, sData, sError) ) // Retrieve the URL page data. { string sSrcData = StringToUpper(sData); string sBeginPairTag = StringConcatenate("<", RQL_KEY_VALUE_PAIR_TAG, ">"); string sEndPairTag = StringConcatenate("</", RQL_KEY_VALUE_PAIR_TAG, ">"); nKeyBeginIndex = StringFind(sSrcData, sBeginPairTag, nKeyBeginIndex); // Keep search for <data></data>, and then parse the contents between them,. while (nKeyBeginIndex > 0) { int nKeyEndIndex = StringFind(sSrcData, sEndPairTag, nKeyBeginIndex + StringLen(sBeginPairTag)); if( nKeyEndIndex > 0 ) { string sPairTag = StringSubstr(sData, nKeyBeginIndex + StringLen(sBeginPairTag), nKeyEndIndex - nKeyBeginIndex - StringLen(sBeginPairTag)); nKeyBeginIndex = nKeyEndIndex + StringLen(sEndPairTag); string sKey = "", sValue = ""; if( getXmlTagData(sPairTag, RQL_KEY_TAG, sKey) ) { if( StringLen(sKey) > 0 ) { if( getXmlTagData(sPairTag, RQL_VALUE_TAG, sValue) ) { sParams[nParamCount] = sKey; sValues[nParamCount] = sValue; nParamCount++; if( nParamCount >= RQL_MAX_PARAMS ) break; } } } } else break; } } if( nParamCount > 0 ) bSuccess = true; else { if( !getXmlTagData(sData, RQL_ERROR_TAG, sError) ) sError = "Invalid format or no data."; } return (bSuccess); } ////////////////////////////////////////////////////////////////////////////////////////// // Function : getXmlTagData // Purpose : Retrieves the data within the specified XML tag. // Returns TRUE if the tag was found, otherwise returns FALSE. // Inputs : sInput - The input data. // sTag - The tag within which to search. // sData - The output data. // E.g. If sInput is "<param>S1</param><value>44</value>" and sTag = "param", then // returns "S1" since it is between <param> and </param> ////////////////////////////////////////////////////////////////////////////////////////// bool getXmlTagData(string sInput, string sTag, string &sData) { bool bFound = false; string sSrcData = StringToUpper(sInput); string sBeginPairTag = StringConcatenate("<", sTag, ">"); string sEndPairTag = StringConcatenate("</", sTag, ">"); int nBeginIndex = StringFind(sSrcData, sBeginPairTag); if( nBeginIndex >= 0 ) { int nEndIndex = StringFind(sSrcData, sEndPairTag, nBeginIndex + StringLen(sBeginPairTag)); if( nEndIndex > 0 ) { string sItem = StringSubstr(sInput, nBeginIndex + StringLen(sBeginPairTag), nEndIndex - nBeginIndex - StringLen(sBeginPairTag)); sItem = StringTrimRight(StringTrimLeft(sItem)); sData = sItem; return (true); } else return (false); } else return (false); } ////////////////////////////////////////////////////////////////////////////////////////// // Function : getUrlData // Purpose : Retrieves the contents of the specified URL. // Returns true if successful, otherwise returns false. // Inputs : sUrl - The URL to query. // Outputs : sPageData - The URL contents. // sError - The error message in case an error was encounted. ////////////////////////////////////////////////////////////////////////////////////////// bool getUrlData(string sUrl, string &sPageData, string &sError) { int sReadBuffer[256], lia_24[1], li_40; string sBuffer; sPageData = ""; int hConnect = InternetAttemptConnect(0); if (hConnect != 0) { sError = "Unknown error attempting to connect to Internet."; return (false); } int hInet = InternetOpenA("Microsoft Internet Explorer", 0, "", "", 0); if (hInet <= 0) { sError = "Unknown error while attempting to acquire internet session."; return (false); } int hURL = InternetOpenUrlA(hInet, sUrl, "", 0, -2080374528, 0); if (hURL <= 0) { InternetCloseHandle(hInet); sError = "Unable to find requested URL."; return (false); } while (!IsStopped()) { for (int nIndex = 0; nIndex < 256; nIndex++) sReadBuffer[nIndex] = 0; li_40 = InternetReadFile(hURL, sReadBuffer, 1024, lia_24); if (lia_24[0] == 0) break; sBuffer = ""; for (nIndex = 0; nIndex < 256; nIndex++) { sBuffer = sBuffer + CharToStr(sReadBuffer[nIndex] & 255); if (StringLen(sBuffer) == lia_24[0]) break; sBuffer = sBuffer + CharToStr(sReadBuffer[nIndex] >> 8 & 255); if (StringLen(sBuffer) == lia_24[0]) break; sBuffer = sBuffer + CharToStr(sReadBuffer[nIndex] >> 16 & 255); if (StringLen(sBuffer) == lia_24[0]) break; sBuffer = sBuffer + CharToStr(sReadBuffer[nIndex] >> 24 & 255); } sPageData = sPageData + sBuffer; Sleep(1); } InternetCloseHandle(hInet); if (sPageData == "") { sError = "No data."; return (false); } return (true); } ////////////////////////////////////////////////////////////////////////////////////////// // Function : StringToUpper // Purpose : Converts the passed string to upper case and returns it. ////////////////////////////////////////////////////////////////////////////////////////// string StringToUpper(string sText) { int nFindIndex = 0; string sOutput = ""; string sLowerSet = "abcdefghijklmnopqrstuvwxyz"; string sUpperSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; for (int i = 0; i < StringLen(sText); i++) { nFindIndex = StringFind(sLowerSet, StringSubstr(sText, i, 1), 0); if (nFindIndex >= 0) sOutput = sOutput + StringSubstr(sUpperSet, nFindIndex, 1); else sOutput = sOutput + StringSubstr(sText, i, 1); } return (sOutput); } ////////////////////////////////////////////////////////////////////////////////////////// // Function : SymbolsList // Purpose : Returns the list of Symbols supported by MT4. ////////////////////////////////////////////////////////////////////////////////////////// int SymbolsList(string &Symbols[]) { string SymbolsFileName = "symbols.sel"; int hFile = FileOpenHistory(SymbolsFileName, FILE_BIN|FILE_READ); if(hFile < 0) return(-1); int SymbolsNumber = (FileSize(hFile) - 4) / 128; int Offset = 116; ArrayResize(Symbols, SymbolsNumber); FileSeek(hFile, 4, SEEK_SET); for(int i = 0; i < SymbolsNumber; i++) { Symbols[i] = FileReadString(hFile, 12); FileSeek(hFile, Offset, SEEK_CUR); } FileClose(hFile); return(SymbolsNumber); } ////////////////////////////////////////////////////////////////////////////////////////// // Function : publishQuote // Purpose : Publishes the quotes to the server, and returns the result. // Inputs : sURL - The PHP publish URL. // sSymbol - The symbol string. // dPrice - The bid price. // dtTime - The Broker Time (UNIX timestamp). // Outputs : sError - The error message if any. ////////////////////////////////////////////////////////////////////////////////////////// bool publishQuote(string sURL, string sSymbol, double dPrice, datetime dtTime, string &sError) { // Create the HTTP PHP posting URL. string sPostUrl = StringConcatenate(sURL, "?s=", sSymbol, "&p=", dPrice, "&t=", dtTime); string sResult = ""; sError = ""; // Post the data. if( getUrlData(sPostUrl, sResult, sError) ) { // We have got result. // Search for <success> tag. If we find it, then posting was successful. if( StringFind(StringToUpper(sResult), "<" + RQL_QUOTES_SUCCESS_TAG + ">") >= 0 ) return (true); else { // Otherwise, search for <error>.....</error> tag. // If we find it return the error message. sError = "Unknown error."; string sErrorCode = ""; getXmlTagData(sResult, RQL_ERROR_TAG, sErrorCode); if( StringLen(sErrorCode) > 0 ) sError = sErrorCode; return (false); } } else return (false); }
Thank you for any assistance in advance!
int InternetOpenA(string a0, int a1, string a2, string a3, int a4); int InternetOpenUrlA(int a0, string a1, string a2, int a3, int a4, int a5);
- Don't know what/were your compile error is.
- Since build 600 all mt4 strings are Unicode. Those ANSI functions will not work. Find an updated library.
- Your SymbolsList could be rewritten to use the new functions SymbolName - MQL4 Documentation
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
Hello,
I believe this is a simple issue (however I'm not a developer) but I'm trying to get this old code to compile on the new 600+ builds. The error I'm getting is:
'start' - function already defined and has body
I don't understand this because i can't find a "start" anywhere else in the code so not sure how it's already define. I was hoping that someone might be able to change it around and paste the full code again so I can just copy and paste it and try to compile again? Thank you!!