Errors, bugs, questions - page 2633

 

2310
Strange behavior.
If you set an array starting with the fourth parameter, or the fifth, sixth, etc.

void Func(int arg1, int arg2, int arg3=0, double & array[])
{
 
}

the compiler generates an error

'array' - missing default value for parameter

I rearrange the array with the first, or second, or third parameter, no error.

void Func(int arg1, int arg2, double & array[] int arg3=0)
{
 
}


Second strange behaviour.
In the editor on F5, after compiling often triggers script runtime.

 
Roman:

2310
This is strange behavior.
If you set the array starting with the fourth parameter, or the fifth, sixth, etc.

the compiler generates an error

I rearrange the array with the first, or second, or third parameter, no error.


Second strange behaviour.
In the editor by F5, after compilation, it often triggers a program run.

If there is a default value for one of the parameters, then all subsequent parameters should also have default values.

void Func(int arg1, int arg2, int arg3=0, double & array[]  )
{
 
}

This was the behaviour from the beginning.

And it's not about the array, it's about the default value that the last argument has. All subsequent ones must have it as well:

void Func(int arg1, int arg2, double & array[] int arg3=0)
{
 
}
 
Artyom Trishkin:

If there is a default value for one of the parameters, then all subsequent parameters should also have default values.

This was the behaviour from the beginning.

And it's not about the array, it's about the default value of the last argument. All subsequent ones are required to have it as well:

Thanks for the clarification, but the behaviour is strange ))

 
Artyom Trishkin:

So your ranking isn't good enough for blogs yet.

Where can I read about it? What kind of rating do you need? What do you need to do?
 
Roman:

Thanks for the clarification, but the behaviour is strange ))

It's strange to hear you ask such questions. The handbook clearly states


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

If it works on the tester too, that's good. I'll check.

no, it doesn't.

The server time, by the way, does not stop on Saturday. here is the opposite: in the terminal, the server time is updated with the arrival of a new quote. For example, you have only one symbol open in the market overview (not only in the tester, but also in reality). and there are no ticks for five seconds - all this time the server time timer will not move. this applies to Saturday: the server time is running, but the terminal does not know about it, because there are no ticks. the tester will simply miss this period.

 
Petros Shatakhtsyan:

But here I don't know how to determine whether it's a Saturday or not. After all, after the market closes, server time stops.

For what purpose? To run auto-optimisation at the weekend? Then setting a timer from OnTick at a distance of a few minutes would work. If it works, then the ticks have stopped and you can optimise.

If for other purposes, formulate them.

 
Alexey Viktorov:

It is strange to hear you ask such questions. The handbook clearly states


Thanks Alexey, I haven't looked in the guide on this subject )).
Because I rarely use default parameters, but I had to, so I stumbled upon it.
Always thought for some reason that the parameters do not have priority ranking, but they do.

 

Can you tell me how to set the size of a matrix, from the passed arguments.
Something like this

void MxResize(int row, int col)
{
   int A[][];      

   ArrayResizeRow(A, row);    
   ArrayResizeCol(A, col);      
}

The entry below fails, - invalid index value

void MxResize(int row=1, int col=1)
{
   int A[row][col];    
      
}
 
Roman:

Can you tell me how to set the size for a matrix, from the arguments passed.

https://www.mql5.com/ru/forum/328008/page2#comment_14166682

Размерность многомерных динамических массивов через ArrayResize
Размерность многомерных динамических массивов через ArrayResize
  • 2019.12.09
  • www.mql5.com
Добрый день. Такой вопрос волнует: как использовать ArrayResize для двумерных динамических массивов...