Questions from a "dummy" - page 124

 
MetaDriver:

OK, I'm off. :) I'm also outside the terminal.

Checked elementary - trying to use ArrayResize(...)

Judging by the phrase "trying to use" you'll most likely get an error of "array is static" type. Well, let's check it.
 
MetaDriver:

It's elementary to try to use ArrayResize(...)

taki somewhat convoluted) simpler
 

Well here are the mistakes. Citizens of Metaquotes, please pay attention !!!

   int j[1];
   Alert("Размер массива из одного элемента без списка инициализации = ", sizeof(j), "   Массив динамический? ", ArrayIsDynamic(j));

   int k[];
   Alert("Размер структуры для динамического массива = ", sizeof(k), "   Массив динамический? ",ArrayIsDynamic(k));
   
   int g[] = {0};
   Alert("Размер массива из одного элемента со списком инициализации = ", sizeof(g), "   Массив динамический? ",ArrayIsDynamic(g));
The essence of the error: when an initialization list (int g[] = {0}; ) is used for an array, thesizeof(g) function gives the size of struct MqlArrayObject (created for a dynamic array).
Документация по MQL5: Основы языка / Операции и выражения / Другие операции
Документация по MQL5: Основы языка / Операции и выражения / Другие операции
  • www.mql5.com
Основы языка / Операции и выражения / Другие операции - Документация по MQL5
 
220Volt:
The essence of the error: when an initialization list (int g[] = {0}; ) is used for an array, thesizeof(g) function prints the size of struct MqlArrayObject (created for a dynamic array).
And at the same time, ArrayIsDinamic() says that the array is static?
 
MetaDriver:
And ArrayIsDinamic() says that the array is static?

j - static

k - dynamic

g - static

 
220Volt:
....

g - static

Terrible. Write to Sportlotto. I'll back it up.
 
220Volt:

Well here are the mistakes. Citizens of the Metacities, please pay attention !!!

The essence of the error: when an initialization list (int g[] = {0}; ) is used for an array, functionsizeof(g) gives out the size of struct MqlArrayObject (created for dynamic array).

Thank you for the message, the error has been corrected.
 
mql5:
Thanks for the message, error corrected.

Ilyas!!! Wait a minute!!!

How exactly was it fixed? Did the arrays that were parsed in the declaration become dynamic (resizable)?

Or completely static?

Документация по MQL5: Основы языка / Переменные
Документация по MQL5: Основы языка / Переменные
  • www.mql5.com
Основы языка / Переменные - Документация по MQL5
 
MetaDriver:

Or is it completely static?
Static, of course.
 
Renat:
It's a static code, of course.

Oh, now I see.

Renat, I have a suggestion for a long time, just on the subject. Please make a named typing for arrays, at least for static ones (all other types already have it).

That is, you may declare for example: typedef Int8 = int[8];.

The price of the question is the possibility to pass one-dimensional (2, 3-dimensional) arrays, which are subarrays in arrays of larger size, into functions.

I.e. if you declare : Int8 arr[...] further, you can pass arr[i] into function func(Int8 &a) {...}.

Currently, I have to perform a lot of extra actions in mql5 and write a lot of ugly code due to impossibility to pass subarrays into functions.

I don't write in servicedesk, because the topic seems debatable to me.

Общайтесь с разработчиками через Сервисдеск!
Общайтесь с разработчиками через Сервисдеск!
  • www.mql5.com
Ваше сообщение сразу станет доступно нашим отделам тестирования, технической поддержки и разработчикам торговой платформы.