Errors, bugs, questions - page 2258

 
Anatoli Kazharski:

You need to be able to track changes in the properties of all charts, not just the one on which the MQL program is placed.

Make a crutch through a timer.

 
fxsaber:

Make a crutch through the timer.

I don't want to make a crutch. MQ developers can expand possibilities.

Forum on trading, automated trading systems & strategy testing

Bugs, bugs, questions

Anatoli Kazharski, 2018.08.20 08:11

I want to be able to track changes in properties of all charts, not only the one where MQL-program is placed.

Right now theCHARTEVENT_CHART_CHANGE event does not contain any other parameters:

Event

Parameter value id

parameter value lparam

parameter value dparam

Parameter value sparam

The event of changing the chart dimensions or changing the chart properties via properties dialog

CHARTEVENT_CHART_CHANGE

-

-

-

//---

To track this event on other open charts, monitoring could be enabled by specifying the ID of the desired chart.

For example, like this:

ChartSetInteger(chart_id,CHART_EVENT_CHART_CHANGE,true);
//---


As lparam-parameter could be the identifier of the chart on which changes were made. The sparam parameter could be the name of the symbol.

 
A100:

Error during execution:

Result: Expected:

A::f<int>:1 A::f<int>:1
A::f<int>:753790661 A::f<int>:2
A::f<int>:Error:4007

Otherwise:

Fine. What's the difference? Why did the array size suddenly become 753790660 (instead of one) and as a consequence memory suddenly ran out (4007) ? MT5\1881\32

Moreover... if you delete literally three characters in the class in the first case, the result will also be ok

Thanks for the message.

Fixed.


To work in current build, do not specify class scop when declaring its methods.


Other bug reports are related to this one and will not be reproduced after the fixes are made.

 

the example from the help does not work:

https://www.mql5.com/ru/docs/basis/function/operationoverload

the example at the very bottom of the page does not work, from the words:

Другой пример перегрузки операции индексирования - работа с матрицами. Матрица представляет собою двумерный динамический массив, размеры массивов заранее неопределены. Поэтому нельзя объявить массив вида array[][] без указания размера второго измерения и затем передавать этот массив в качестве параметра. Выходом может служить специальный класс CMatrix, который содержит в себе массив объектов класса CRow.

the compiler writes:

object of 'CMatrix' cannot be returned, copy constructor 'CMatrix::CMatrix(const CMatrix &)' not found tst.mq5 244 14

object of 'CMatrix' cannot be returned, copy constructor 'CMatrix::CMatrix(const CMatrix &)' not found tst.mq5 261 11

object of 'CMatrix' cannot be returned, copy constructor 'CMatrix::CMatrix(const CMatrix &)' not found tst.mq5 281 14

object of 'CMatrix' cannot be returned, copy constructor 'CMatrix::CMatrix(const CMatrix &)' not found tst.mq5 303 11

4 error(s), 0 warning(s) 5 1




Документация по MQL5: Основы языка / Функции / Перегрузка операций
Документация по MQL5: Основы языка / Функции / Перегрузка операций
  • www.mql5.com
Перегрузка операций позволяет использовать операционную нотацию (запись в виде простых выражений) к сложным объектам - структурам и классам. Запись выражений с использованием перегруженных операций упрощает восприятие исходного кода, так как более сложная реализация сокрыта. Для примера рассмотрим широко применяемые в математике комплексные...
 

Compilation error (ME\1881\32)

template<typename T>
class B;
template<typename T>
class A {
        B<int> *f() { return NULL; }
};
template<typename T>
class B : public A<T> {}; //Error: 'A' - struct undefined
void OnStart()
{
        A<int> *a;
        B<int> *b;
}

And so:

void OnStart()
{
        B<int> *b;
        A<int> *a;
}
fine. What difference does it make?
 
fxsaber:

This is not the reason.

this helps a lot when reading code and helps avoid errors in some situations.

Note that this in MQL does not work everywhere:

class A { protected:
        int a;
};
class B : public A {
        int a;
        void f1() { this.a    = 0; } //нормально
        void f2() { this.A::a = 0; } //Error: '::' - syntax error
};

that in C++ it compiles without error

 
A100:

Note that this in MQL does not work everywhere:

that in C++ compiles without error

C++ has a knack for perversion. Perhaps somewhere in macros this could be used, but not directly.

 
In the top-right corner I keep seeing an icon saying I have unread PMs. There's no way to reset it - it's read. Please add a "Make all read" button.
 
fxsaber:

It may be possible to use this somewhere in macros, but not directly.

Macros have nothing to do with it at all - replace this with a normal pointer and you have exactly the same syntax:

struct A {
        int x;
};
struct B : A {
        int x;
};
void OnStart()
{
        B b;
        b.A::x = 1; //Error: '::' - syntax error
}
In MQL you cannot explicitly refer to b.A::x, while in C++ you can. Why such a restriction?
 
A100:

Macros have nothing to do with it at all - replace this with an ordinary pointer and you have exactly the same syntax:

In this case it's justified. The variant with this - it's not clear why to write it that way. When A:: already says it all.