FileWriteArray

 

I have just reported this to service desk but I was wondering if anybody else having same problem.

I cannot create dat or csv files from an array even though the array has data.

 

Hey guys any response from Metaquotes here will be helpful. 

This code is not working

      string m_file = "-Weights-";
      string BufferWeights[8][8];//Static array declared globally but shown here for clarity
      int handle = FileOpen(m_file+".dat",FILE_READ|FILE_WRITE|FILE_BIN);
      if(handle!=INVALID_HANDLE)
      {
         FileWriteArray(handle,BufferWeights,0,WHOLE_ARRAY);
         FileClose(handle);
      }
      if(handle==INVALID_HANDLE)
      {
         printf(__FUNCTION__+": error writing weights to file");
      }

I have also tried this but I get same results

       int handle = FileOpen(m_file+".dat",FILE_SHARE_WRITE|FILE_WRITE|FILE_BIN);


      int handle = FileOpen(m_file+".dat",FILE_SHARE_WRITE|FILE_READ|FILE_WRITE|FILE_BIN);


Please help

 
Strings cannot be written to a binary file. Use FILE_TXT instead of FILE_BIN to open a text file.
Documentation on MQL5: Standard Constants, Enumerations and Structures / Input/Output Constants / File Opening Flags
  • www.mql5.com
Standard Constants, Enumerations and Structures / Input/Output Constants / File Opening Flags - Documentation on MQL5
 
mql5:
Strings cannot be written to a binary file. Use FILE_TXT instead of FILE_BIN to open a text file.

Спасибо Мистер MQL5
 
mql5:
Strings cannot be written to a binary file. Use FILE_TXT instead of FILE_BIN to open a text file.

 Can someone please help me with reading array files. This code now keeps throwing up error 5004

 

      
      //-----------------------------------------------------------------------------------------------------
      //All these options for the file path of the read file, "m_weights_file", throw up errors 5004 or 5002
      //-----------------------------------------------------------------------------------------------------

      m_weights_file = /*TerminalInfoString(TERMINAL_DATA_PATH)+"\\MQL5\\"+*/"SOMWeights " + IntegerToString(ArraySize(GridWeights))+".dat";
      //m_weights_file="D:\Program Files\MetaTrader 5\MQL5\Files\SOMWeights 20736.dat";
      int handle = FileOpen(m_weights_file,FILE_READ|FILE_TXT|FILE_ANSI);
      
      if(handle!=INVALID_HANDLE)
      {
         printf(__FUNCTION__+" Read array!! ");
         FileReadArray(handle,GridWeights,0,WHOLE_ARRAY);
         FileClose(handle);
      }
      if(handle==INVALID_HANDLE)
      {  
         printf(__FUNCTION__+" unable to read array @ "+m_weights_file+" !!... "+string(GetLastError()));// this is the error I keep getting...
      }

 

 

Any help on resolving this will be highly appreciated. The .dat file stores strings written from an array. 

 
ssn:

 Can someone please help me with reading array files. This code now keeps throwing up error 5004

 

 

 

Any help on resolving this will be highly appreciated. The .dat file stores strings written from an array. 

The tester file property is also not workin...


#property tester_file "SOMWeights 20736.dat"

      
      //--- 

      m_weights_file="SOMWeights 20736";
      int handle = FileOpen(m_weights_file,FILE_READ|FILE_TXT|FILE_ANSI);

      //same code as above...

  I still get error 5004 despite the fact that the file is present in the MQL5\files directory.

Read Array Error 

 
m_weights_file="SOMWeights 20736";
Where extension?
 
Hey I thought this works like a custom indicator but I added the extension and it finally worked. Thanks a lot man.... would have bought you a vodka if we were in the same town. Thanks.
Step on New Rails: Custom Indicators in MQL5
  • 2009.11.23
  • Андрей
  • www.mql5.com
I will not list all of the new possibilities and features of the new terminal and language. They are numerous, and some novelties are worth the discussion in a separate article. Also there is no code here, written with object-oriented programming, it is a too serous topic to be simply mentioned in a context as additional advantages for developers. In this article we will consider the indicators, their structure, drawing, types and their programming details, as compared to MQL4. I hope that this article will be useful both for beginners and experienced developers, maybe some of them will find something new.
Reason: