How to write a file without remove old content?

 

I want to record spread,and input them to mysql,so I can do some statistics.The following is my code,but my problem is every time the new content will remove old content.So can someone tell me how to write new content without remove old content? Thank you very much!

int start()
{
 int    handle;
 string insert_time,double_quotes;
 double spread;
 handle=FileOpen("filename.sql", FILE_CSV|FILE_WRITE, ',');
 
 double_quotes = "\"";
 insert_time = double_quotes+Year()+"-"+Month()+"-"+Day()+" "+Hour()+":"+Minute()+":"+Seconds()+double_quotes;
 spread = (Ask - Bid) * 10000;
 
 if(handle>0)
 {
  FileWrite(handle,insert_time,spread);
  FileClose(handle);
 }
 else
 {
  Print(GetLastError());
 }
 return(0);
}
 
Try adding a FileSeek() to SEEK_END
 
RaptorUK:
Try adding a FileSeek() to SEEK_END

Thank you very much,problem solved.

I looked this function before I post this topic,I don't know why I didn't use it.Thanks anyway!

 

overwrite (or create):

handle=FileOpen("filename.sql", FILE_CSV|FILE_WRITE, ',');

(seeking to the end of an empty file does nothing)


appending:

        int     APPEND  = FILE_CSV|FILE_WRITE|FILE_READ;
        int     handleOPT       = FileOpen(nameOPT, APPEND, '~');
        if (handleOPT < 1){ ... }
        FileSeek(handleOPT, 0, SEEK_END);
 

hi guys...i'm newbie here...anybody now how to make my indicator of trendline that have vertical line price for High price 1 and 2 then lowprice1 and 2, how to export that price to my specific coloumn in my excell file.

i need that...thanks before.

 
semarfx:
i'm newbie here...anybody now how to make my indicator
  1. Don't hijack someone else's thread, post your own.
  2. Since there are no slaves here, there are only two choices: learn to code or pay someone. We're not going to code it FOR you. We are willing to HELP you.
Reason: