FileOpen function does not work.

 

[environment]

Oanda MT4 build 1280


[Description]

I run the code below, "FileOpen" does not work(no file created).

I could not find the error code even "GetLastError"(result is 0).

int OnInit() {

         int handle; //file handler
         string FILE_NAME = "sample.txt";

         //file open

         handle = FileOpen(FILE_NAME, FILE_CSV|FILE_READ|FILE_WRITE,'\t');

         if (handle <= 0){

            Print("file open error", GetLastError())

            return(-1);

         }

         //ouput log

         FileSeek(handle,0, SEEK_END);

         FileWrite(handle,TimeToStr(Time[0]), "sample_string");

         //file close

         FileClose(handle);

}


Once I run the code, I look into the folder below.

my terminal path/MQL4/Files/

There is no new file found..


is there any clue on this?

much appreciate any comment.

Regards,

OOP in MQL5 by Example: Processing Warning and Error Codes
OOP in MQL5 by Example: Processing Warning and Error Codes
  • www.mql5.com
Before we start developing, let's get acquainted with some features of the OOP, which will be used in this article.  Of course, we will use structures and classes. These are the basics of object oriented languages. A structure is a construction that allows containing a set of variables and functions of different types (except void). A class as...
 
Please edit your post and
use the code button (Alt+S) when pasting code
 
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor

  2. We have no idea what FILE_NAME is. Always post all relevant code.
         How To Ask Questions The Smart Way. 2004
              Be precise and informative about your problem
  3. try_argo: "FileOpen" does not work(no file created).
    How to you know that? Where are you looking?
 

thanks for your notice, edit the post as you noted.

Keith Watford:
Please edit your post and
use the code button (Alt+S) when pasting code
 

Thanks for your comment, I edit the post.

regarding #3, I look into the folder(my terminal path/MQL4/Files/), no new file found.

William Roeder:
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor

  2. We have no idea what FILE_NAME is. Always post all relevant code.
         How To Ask Questions The Smart Way. 2004
              Be precise and informative about your problem
  3. How to you know that? Where are you looking?
 
try_argo: regarding #3, I look into the folder(my terminal path/MQL4/Files/), no new file found.

Did you get your “my terminal path” by opening the Data Folder or are you guessing? Are you running live or using the tester?

Reason: