From acea728072e23a56bb10034a64c6ff0eb295f311 Mon Sep 17 00:00:00 2001 From: Ding Li Date: Sun, 7 Apr 2019 11:01:20 +0800 Subject: [PATCH] Fix MQL language compatibility with latest version of MT4 (no automatic conversion of integer to boolean) --- Lang/GlobalVariable.mqh | 8 ++++---- Trade/Terminal.mqh | 18 +++++++++--------- UI/Chart.mqh | 6 +++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Lang/GlobalVariable.mqh b/Lang/GlobalVariable.mqh index 6b42888..1dab662 100644 --- a/Lang/GlobalVariable.mqh +++ b/Lang/GlobalVariable.mqh @@ -34,12 +34,12 @@ public: static bool makeTemp(string name) {return GlobalVariableTemp(name);} static double get(string name) {return GlobalVariableGet(name);} - static bool get(string name,double &value) {return GlobalVariableGet(name,value);} - static datetime set(string name,double value) {return GlobalVariableSet(name,value);} + static bool get(string name,double &value) {return (bool)GlobalVariableGet(name,value);} + static bool set(string name,double value) {return (bool)GlobalVariableSet(name,value);} static bool setOn(string name,double value,double check) {return GlobalVariableSetOnCondition(name,value,check);} - static bool remove(string name) {return GlobalVariableDel(name);} - static bool removeAll(string prefix=NULL,datetime before=0) {return GlobalVariablesDeleteAll(prefix,before);} + static bool remove(string name) {return (bool)GlobalVariableDel(name);} + static bool removeAll(string prefix=NULL,datetime before=0) {return (bool)GlobalVariablesDeleteAll(prefix,before);} }; //+------------------------------------------------------------------+ //| TempVar is a variable whose life time is the same as the program | diff --git a/Trade/Terminal.mqh b/Trade/Terminal.mqh index 5a834fb..fcba32c 100644 --- a/Trade/Terminal.mqh +++ b/Trade/Terminal.mqh @@ -30,9 +30,9 @@ public: static bool isStopped() {return IsStopped();} static bool isConnected() {return IsConnected();} - static bool hasCommunityAccount() {return TerminalInfoInteger(TERMINAL_COMMUNITY_ACCOUNT);} - static bool isCommunityConnected() {return TerminalInfoInteger(TERMINAL_COMMUNITY_CONNECTION);} - static double getCommunityBalance() {return TerminalInfoDouble(TERMINAL_COMMUNITY_BALANCE);} + static bool hasCommunityAccount() {return (bool)TerminalInfoInteger(TERMINAL_COMMUNITY_ACCOUNT);} + static bool isCommunityConnected() {return (bool)TerminalInfoInteger(TERMINAL_COMMUNITY_CONNECTION);} + static double getCommunityBalance() {return (bool)TerminalInfoDouble(TERMINAL_COMMUNITY_BALANCE);} static string getPath() {return TerminalInfoString(TERMINAL_PATH);} static string getDataPath() {return TerminalInfoString(TERMINAL_DATA_PATH);} @@ -51,13 +51,13 @@ public: static string getTerminalCompany() {return TerminalInfoString(TERMINAL_COMPANY);} static string getTerminalLanguage() {return TerminalInfoString(TERMINAL_LANGUAGE);} - static bool isDllAllowed() {return TerminalInfoInteger(TERMINAL_DLLS_ALLOWED);} - static bool isTradeAllowed() {return TerminalInfoInteger(TERMINAL_TRADE_ALLOWED);} - static bool isEmailEnabled() {return TerminalInfoInteger(TERMINAL_EMAIL_ENABLED);} - static bool isFtpEnabled() {return TerminalInfoInteger(TERMINAL_FTP_ENABLED);} + static bool isDllAllowed() {return (bool)TerminalInfoInteger(TERMINAL_DLLS_ALLOWED);} + static bool isTradeAllowed() {return (bool)TerminalInfoInteger(TERMINAL_TRADE_ALLOWED);} + static bool isEmailEnabled() {return (bool)TerminalInfoInteger(TERMINAL_EMAIL_ENABLED);} + static bool isFtpEnabled() {return (bool)TerminalInfoInteger(TERMINAL_FTP_ENABLED);} - static bool isNotificationsEnabled() {return TerminalInfoInteger(TERMINAL_NOTIFICATIONS_ENABLED);} - static bool hasMetaQuotesId() {return TerminalInfoInteger(TERMINAL_MQID);} + static bool isNotificationsEnabled() {return (bool)TerminalInfoInteger(TERMINAL_NOTIFICATIONS_ENABLED);} + static bool hasMetaQuotesId() {return (bool)TerminalInfoInteger(TERMINAL_MQID);} static bool notify(string msg); static bool mail(string subject,string content); diff --git a/UI/Chart.mqh b/UI/Chart.mqh index e6ef280..6b4da51 100644 --- a/UI/Chart.mqh +++ b/UI/Chart.mqh @@ -90,11 +90,11 @@ public: int getSubwindowHeight(int index=0) const {return(int)ChartGetInteger(m_chartId,CHART_HEIGHT_IN_PIXELS,index);} bool setSubwindowHeight(int index,int height) {return ChartSetInteger(m_chartId,CHART_HEIGHT_IN_PIXELS,index,height);} - bool isOffline() const {return ChartGetInteger(m_chartId,CHART_IS_OFFLINE);} + bool isOffline() const {return (bool)ChartGetInteger(m_chartId,CHART_IS_OFFLINE);} #define BOOL_PROP(PropName,OptionName) \ - bool is##PropName() const {return ChartGetInteger(m_chartId,OptionName);}\ - bool set##PropName(bool value) {return ChartSetInteger(m_chartId,OptionName,value);} + bool is##PropName() const {return (bool)ChartGetInteger(m_chartId,OptionName);}\ + bool set##PropName(bool value) {return (bool)ChartSetInteger(m_chartId,OptionName,value);} BOOL_PROP(ShowOHLC,CHART_SHOW_OHLC) BOOL_PROP(ShowBidLine,CHART_SHOW_BID_LINE)