I haven't tested this out, but, the same principle should apply. If 
you are only running the script once a day, with each day's new data 
each time, then you can try something along the lines of:

filename = "d:\\newfold\\myfile" + LastValue(Year()) + LastValue(Month
()) + LastValue(Day()) + ".txt";
fh = fopen( filename, "a");

If you run multiple times a day, you will clobber the file of the 
current date each time. In such cases, you might want to append the 
time to the file name too (e.g. Hour(), Minute(), Second()).

Mike

--- In [email protected], "J. Biran" <[EMAIL PROTECTED]> wrote:
>
> 
> No, I meant 
> fh = fopen( "d:\\newfold\\msdata.txt", "a");
> where msdata is a string that is dynamically constructed in
> the afl and takes input from Date()
> 
> This should prevent overwriting old files.
> 
> Joseph Biran
> ____________________________________________
> -----Original Message-----
> From: [email protected]
> [mailto:[EMAIL PROTECTED] On Behalf Of Mike
> Sent: Tuesday, July 01, 2008 2:23 PM
> To: [email protected]
> Subject: [amibroker] Re: How to write to a file with a
> dynamic name including a date
> 
> You can use any valid filename that you want.
> 
> Assuming that you will be looping through bars, you can just
> use the 
> Day(), Month(), Year() functions, then construct your file
> name using 
> the indexed value on a bar by bar basis.
> 
> See this library example for reference: 
> http://www.amibroker.com/library/detail.php?id=1044&hilite=Y
> EAR
> 
> You will, of course, have to modify it to suit your needs.
> But, the 
> concept of iterating through bars and accessing the
> individual 
> year/month/day is illustrated. Combine this with
> fopen/fputs/fgets 
> and you should be good to go:
> 
> http://www.amibroker.com/guide/afl/afl_view.php?id=225
> 
> Mike
> 
> --- In [email protected], "J. Biran" <jbiran@>
> wrote:
> >
> > 
> > Is there a simple way in afl to read / write to a file
> which
> > name includes the date? 
> > i.e. myfile20080701.txt 
> > 
> > Joseph Biran
> > ____________________________________________
> >
> 
> 
> 
> ------------------------------------
> 
> Please note that this group is for discussion between users
> only.
> 
> To get support from AmiBroker please send an e-mail directly
> to 
> SUPPORT {at} amibroker.com
> 
> For NEW RELEASE ANNOUNCEMENTS and other news always check
> DEVLOG:
> http://www.amibroker.com/devlog/
> 
> For other support material please check also:
> http://www.amibroker.com/support.html
> Yahoo! Groups Links
>


Reply via email to