MT4 tester: file write working only once?

 

Hello,


I want to write some tick information to a file and I use a simple file appending function:

void simpleFileAppend(string fileName, string txt2Append)
{
int handle = FileOpen(fileName,FILE_READ|FILE_WRITE);
FileSeek(handle,0,SEEK_END);
FileWrite(handle,txt2Append);
FileFlush(handle);
FileClose(handle);
}



My problem: on the very first run in MT4 tester the file is written to c:\MT4InstallDir\tester\files\myfile.txt and contains a lot of data, as expected. I then delete the file. After running the tester again and again, the file is never created a second time. Why? Do I miss important information about writing files?


Thank you,

Alex

 
alex99999:

My problem: on the very first run in MT4 tester the file is written to c:\MT4InstallDir\tester\files\myfile.txt and contains a lot of data, as expected. I then delete the file. After running the tester again and again, the file is never created a second time. Why? Do I miss important information about writing files?

Please use this to post code . . . it makes it easier to read.

 
alex99999:

My problem: on the very first run in MT4 tester the file is written to c:\MT4InstallDir\tester\files\myfile.txt and contains a lot of data, as expected. I then delete the file. After running the tester again and again, the file is never created a second time. Why? Do I miss important information about writing files?

The 2nd and subsequent times does the FileOpen() work ? why aren't you checking the handle ? if the handle is -1 the FileOpen() has failed, check the return code and report he error to the log . . .

What are Function return values ? How do I use them ?

 
RaptorUK:

The 2nd and subsequent times does the FileOpen() work ? why aren't you checking the handle ? if the handle is -1 the FileOpen() has failed, check the return code and report he error to the log . . .

What are Function return values ? How do I use them ?


thanks for your help. Got the error now, it was a logical problem on other location.

BTW: yes I know what funcion return values are, but that was a fast test only :-)

Reason: