Hello everybody,
I have tried this:
But compiler says no...
cannot convert 4487 to enum 'ENUM_FILESELECT_FLAGS'
I think you can use int
int flags=(FILE_READ | FILE_WRITE | FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_BIN | FILE_COMMON);The FILESELECT FLAGS enumeration is for the manual file open dialog if i'm not mistaken
Hello everybody,
I have tried this:
But compiler says no...
cannot convert 4487 to enum 'ENUM_FILESELECT_FLAGS'
ENUM_FILESELECT_FLAGS flags=(ENUM_FILESELECT_FLAGS)(FILE_READ | FILE_WRITE | FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_BIN | FILE_COMMON);
Thanks to all, this works:
ENUM_FILESELECT_FLAGS flags= ENUM_FILESELECT_FLAGS(FILE_READ | FILE_WRITE | FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_BIN | FILE_COMMON);
OP does not need to cast the value. The resulting bit mask is not an enum. Do not lie in your code. File open does not take an enum. Change the variable type.
Not sure what this discussion is about...
#include <Files\FileBin.mqh> //--- die Parameter für die Aufzeichnung der Daten in die Datei input string InpFileName = "FileBinTest.txt"; // der Dateiname input string InpDirectoryName = "FileBinTest"; // der Verzeichnisname ENUM_FILESELECT_FLAGS fileselect_flags = ENUM_FILESELECT_FLAGS(FILE_READ | FILE_WRITE | FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_BIN | FILE_COMMON); CFileBin file_bin; MqlTick write_tick[]; MqlTick read_tick[]; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- ArrayResize(write_tick,1); ArrayResize(read_tick,1); file_bin.Open(InpDirectoryName + "//" + InpFileName, fileselect_flags); for(int i=0;i<5;i++) { write_tick[0].time = i; write_tick[0].ask = 1.5; write_tick[0].bid = 1.4; write_tick[0].volume = 200; file_bin.WriteStruct(write_tick[0]); } file_bin.Seek(0,SEEK_SET); for(int i=0;i<5;i++) { file_bin.ReadStruct(read_tick[0]); PrintFormat("time: %s, ask: %s, bid: %s, volume: %s", string(read_tick[0].time), string(read_tick[0].ask), string(read_tick[0].bid), string(read_tick[0].volume)); } //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- ExpertRemove(); } //+------------------------------------------------------------------+
This creates a file in the common folder. I have not come to test if it fulfills all the flags though.
Not sure what this discussion is about...
This creates a file in the common folder. I have not come to test if it fulfills all the flags though.
The discussion is about that combination of binary flags (1,2,4,8,16 etc.. ) with an | operator results in a value which is not one of the values of the originating binary flags enum (for instance 1 | 2 results in 3 which is an int type and not an ENUM_FILESELECT_FLAGS type). This is why the compiler complained initially for you, and this is why the open takes an int type as the 2nd parameter and not an enum. What you did when casting, is forced the value into the ENUM, even though it does not fit there ( 4487 is not defined in the enum) and then passed that enum into FileOpen (which tries to convert it back to int to cover for what you did).
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everybody,
I have tried this:
But compiler says no...
cannot convert 4487 to enum 'ENUM_FILESELECT_FLAGS'