Download MetaTrader 5
To add comments, please log in or register
Have you developed an application? Publish it in Code Base!
virusx1984
13
virusx1984 2015.11.11 16:10 

I saw in the MQL4 Document:

  • If FILE_READ is specified, an attempt is made to open an existing file. If a file does not exist, file opening fails, a new file is not created.
  • FILE_READ|FILE_WRITE – a new file is created if the file with the specified name does not exist.
  • FILE_WRITE –  the file is created again with a zero size.
so the file that exists can't be append? 
Carl Schreiber
5939
Carl Schreiber 2015.11.11 16:47  
Well this is the intended behaviour. What can you read from a file that does not exist?
whroeder1
13605
whroeder1 2015.11.11 18:03  
virusx1984: so the file that exists can't be append? 
Of course you can; open read/write and seek to the end.
virusx1984
13
virusx1984 2015.11.11 23:30  
WHRoeder:
virusx1984: so the file that exists can't be append? 
Of course you can; open read/write and seek to the end.

Thank you! How to seek to the end? Could you give me an example?
whroeder1
13605
whroeder1 2015.11.12 16:14  
virusx1984 How to seek to the end? Could you give me an example?
  1. RTFM List of MQL4 Functions - MQL4 Documentation -> File Functions - MQL4 Documentation -> FileSeek - MQL4 Documentation
  2. RTFB MQL4 Tutorial -> File Operations - Standard Functions - MQL4 Tutorial -> FileSeek - MQL4 Documentation
  3.       int      CREATE   = FILE_WRITE|FILE_TXT|FILE_ANSI;
          int      APPEND   = FILE_READ|CREATE;
          string   fileName = WindowExpertName() + ".DBG";
          HANDLE   handle   = FileOpen(fileName, APPEND);
          if(handle != INVALID_HANDLE){
             FileSeek(handle, 0, SEEK_END);
             FileWrite(handle, s);
             FileClose(handle);
    
    Is that so hard?
/
To add comments, please log in or register