Warning: implicit enum conversion

 

Hi there,

Using : https://www.mql5.com/en/articles/62 to create scripts in order to write and read objects&properties for a panel.

I had no problem for creating the write script (only a little change: FileWriteInteger from article need to replace by FileWriteLong)

However when reading the file to create the objects, I get the warning : implicit enum conversion, here is the lign:

ENUM_OBJECT obj_type=FileReadInteger(handle,4);

Follows the lign:

ObjectCreate(0, obj_name, obj_type, 0, 0, 0); 

 

I have tried to change FileReadInteger to FileReadLong  or even  ENUM_OBJECT to long but no success.

Any ideas or suggestions? Thx...

Maybe the author of the article could do the change/updates to his article. 

Creating Active Control Panels in MQL5 for Trading
  • 2010.05.25
  • Евгений
  • www.mql5.com
The article covers the problem of development of active control panels in MQL5. Interface elements are managed by the event handling mechanism. Besides, the option of a flexible setup of control elements properties is available. The active control panel allows working with positions, as well setting, modifying and deleting market and pending orders.
 
bouchepat:

Hi there,

Using : https://www.mql5.com/en/articles/62 to create scripts in order to write and read objects&properties for a panel.

I had no problem for creating the write script (only a little change: FileWriteInteger from article need to replace by FileWriteLong)

However when reading the file to create the objects, I get the warning : implicit enum conversion, here is the lign:

ENUM_OBJECT obj_type=FileReadInteger(handle,4);

Follows the lign:

ObjectCreate(0, obj_name, obj_type, 0, 0, 0); 

 

I have tried to change FileReadInteger to FileReadLong  or even  ENUM_OBJECT to long but no success.

Any ideas or suggestions? Thx...

Maybe the author of the article could do the change/updates to his article. 

Well regardless of the warning message:

implicit enum conversion && possible loss of data due to type conversion

the script is working fine... but instead of FileReadInteger replace to FileReadLong.... Answer myself, thought it might help someone else. 

 

 
bouchepat:

...

ENUM_OBJECT obj_type=FileReadInteger(handle,4);

... I get the warning : implicit enum conversion

Well, an int, as returned by "FileReadInteger", can, in general, have more values than the enumeration type, so the compiler is warning you that the implicit conversion, as performed by the compiler, may not succeed. However, you can take the responsibility for the conversion by inserting an explicit cast!

ENUM_OBJECT obj_type = (ENUM_OBJECT)FileReadInteger(handle,4);

Cheers!

 
Max Payne # :

Nói chung, một int, như được trả về bởi "FileReadInteger", có thể có nhiều giá trị hơn danh sách kiểu, vì biên dịch đó đang cảnh báo bạn rằng chuyển đổi ngầm, được thực hiện bởi trình biên dịch, có thể không thành công. Tuy nhiên, bạn có thể chịu trách nhiệm về việc chuyển đổi bằng cách chèn một tổ hợp diễn viên rõ ràng!

Chúc mừng!

Thank you ! I get it .

Reason: