MQL4 FileOpen function

 

Hi guys,

I need to add data to an existing file, a cvs file.

On MQL4 reference I found that "If there is a need to add data to an

existing file, it must be opened using combination of FILE_READ |

FILE_WRITE." but does not work.

Every time I launch Metatrader the file reset to zero-length.

Anyone has properly did it?

Thank you in advance,

Obi Wan.

 

AppendToFile

owkenobi:
Hi guys,

I need to add data to an existing file, a cvs file.

On MQL4 reference I found that "If there is a need to add data to an

existing file, it must be opened using combination of FILE_READ |

FILE_WRITE." but does not work.

Every time I launch Metatrader the file reset to zero-length.

Anyone has properly did it?

Thank you in advance,

Obi Wan.

Please try this script code!

I think you missed FileFlush or you didn't use FileSeek to go to the end of the file!

Files:
 
I think you missed FileFlush or you didn't use FileSeek to go to the end of the file!

Yes, I missed FileSeek!

Now it works!

Thank you codersguru.

Obi Wan.

handle=FileOpen(gs_fname, FILE_CSV|FILE_READ, ';');

if (handle<1)

{

FileClose(handle);

handle=FileOpen(gs_fname, FILE_CSV|FILE_READ|FILE_WRITE, ';');

if (handle>0)

{

FileWrite(handle, gs_fname);

FileFlush(handle);

}

}

else

{

FileClose(handle);

handle=FileOpen(gs_fname, FILE_CSV|FILE_READ|FILE_WRITE, ';');

if (handle>0)

{

FileSeek(handle,0,SEEK_END);

}

}

 

Heres the tick logger code, it works great , however I've been trying to integrate into Cybertrader to log stats and orders and I've got it all worked out except I'm getting the error that too many files are open when in fact it only opens it once.... but Im getting close to solving... I'm working on this right now.. but maybe someone will beat me to the punch

Files:
 
codersguru:
Please try this script code! I think you missed FileFlush or you didn't use FileSeek to go to the end of the file!

Hi guru,

I know you work a lot with file handling. How can I get two experts from two brokers to write to the same file?

 

C++ Task!

Nicholishen:
Hi guru, I know you work a lot with file handling. How can I get two experts from two brokers to write to the same file?

This task have to be C++ task! I'll inform you when I update the File Handling DLL!

 

External file handler

Somewhere in the tons of documentation I have read on MetaTrader I saw an external file write routine that could be downloaded. I get odd results sometimes when using the internal file handling so I would like to try this one. Now I cant find it. Anyone knows?

 

I moved your post to this thread.

Also you can look at this thread https://www.mql5.com/en/forum/174329 where I am collecting all the links which can help coders.

 

This thread https://www.mql5.com/en/forum/173436 and this one can be related to your question https://www.mql5.com/en/forum/176646

 

This was what I was looking for

https://www.mql5.com/en/forum/173113

Reason: