[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: How to write to a file with a dynamic name including a date



PureBytes Links

Trading Reference Links

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 amibroker@xxxxxxxxxxxxxxx, "J. Biran" <jbiran@xxx> 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: amibroker@xxxxxxxxxxxxxxx
> [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Mike
> Sent: Tuesday, July 01, 2008 2:23 PM
> To: amibroker@xxxxxxxxxxxxxxx
> 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 amibroker@xxxxxxxxxxxxxxx, "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
>



------------------------------------

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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/