#ifndef LIB_MQLPLUS_MQL4_COMPATIBILITY_ARRAY_MQH_INCLUDED #define LIB_MQLPLUS_MQL4_COMPATIBILITY_ARRAY_MQH_INCLUDED #property version "1.0"; #property strict /********************************************************************************** * Copyright (C) 2010-2022 Dominik Egert * * This file is the MQL4 backward compatibility include file. * * MQLplus, including this file may not be copied and/or distributed * without explecit permit by the author. * Author Dominik Egert / Freie Netze UG. ********************************************************************************** * * Version: 1.0 * State: development * * File information * ================ * * * */ #ifdef DBG_MSG_TRACE_FILE_LOADER DBG_MSG_TRACE_FILE_LOADER; #endif //*********************************************************************************************************************************************************/ // // BEGIN MQL4 compatibility additions // //+------------------------------------------------------------------+ //| MQL4: MQL5-compatible ArrayPrint() | //+------------------------------------------------------------------+ template void ArrayPrint(const T& array[], uint _digits = -1, const string separator = NULL, const ulong start = 0, const ulong count = WHOLE_ARRAY, const ulong flags = ARRAYPRINT_HEADER | ARRAYPRINT_INDEX | ARRAYPRINT_LIMIT | ARRAYPRINT_ALIGN) { // Local init const uint digits = (_digits == ((uint)-1)) ? _Digits : _digits; // Needs implementation printf("Function not implemented: %s", __FUNCTION__); // Return return; } //+------------------------------------------------------------------+ //| MQL4: MQL5-compatible ArrayInsert() | //+------------------------------------------------------------------+ template const bool ArrayInsert(T& dst_array[], const T& src_array[], const uint dst_start, const uint src_start = 0, const uint count = WHOLE_ARRAY) { // Local init T tmp_arr[]; // Copy array data ArrayCopy(tmp_arr, dst_array, 0, dst_start); ArrayCopy(tmp_arr, src_array, dst_start, src_start, count); ArrayCopy(tmp_arr, dst_array, dst_start + count, dst_start); // Return return(true); } //+------------------------------------------------------------------+ //| MQL4: MQL5-compatible ArrayRemove() | //+------------------------------------------------------------------+ template const bool ArrayRemove(T& array[], const uint start, const uint count = WHOLE_ARRAY) { // Local init const int stop = ArraySize(array); int ptr = (int)(start + count); // Shortcut whole array if(count == WHOLE_ARRAY) { return(ArrayResize(array, start) == start); } // Loop array for(int cnt = (int)start; (cnt < stop) && !_StopFlag; cnt++) { array[cnt] = array[ptr]; ptr++; } // Adjust size return(ArrayResize(array, stop - count) == (stop - count)); } //+------------------------------------------------------------------+ //| MQL4: MQL5-compatible ArrayReverse() | //+------------------------------------------------------------------+ template const bool ArrayReverse(T& array[], const uint start, const uint count = WHOLE_ARRAY) { // Local init int high_ptr = (count == WHOLE_ARRAY) ? ArraySize(array) : (start + count); T tmp_val; // Reverse range of array for(int low_ptr = start; (low_ptr < high_ptr) && !_StopFlag; low_ptr++) { tmp_val = array[low_ptr]; array[low_ptr] = array[high_ptr]; array[high_ptr] = tmp_val; high_ptr--; } // Return return(true); } //+------------------------------------------------------------------+ //| MQL4: MQL5-compatible ArraySwap() | //+------------------------------------------------------------------+ template const bool ArraySwap(T& array1[], T& array2[]) { // Local init T tmp_arr[]; // Create copy ArrayCopy(tmp_arr, array1); ArrayCopy(array1, array2); ArrayFree(array2); ArrayCopy(array2, tmp_arr); ArrayFree(tmp_arr); // Return return(true); } // // END MQL compatibility */ //*********************************************************************************************************************************************************/ #endif // LIB_MQLPLUS_MQL4_COMPATIBILITY_ARRAY_MQH_INCLUDED