>I would like to write the results of a GAMS program into a text file
>whose name should depend on the date and time of the run. How could
>that be done?
>
>Ex: output-05.15.08-09.39.txt
>The above is just a sample and it does not have to be exactly the same.
The suggestion to use myfile /filename_%system.date%_%system.time%/ does not work for several reasons: quotes are needed to handle embedded blanks and the ‘/’ characters in the system date cause problems when used inside a file name. Here is a different approach that actually works (I ran it before suggesting it):
The generated include file will look like:$onecho > createfile.awk
BEGIN { print "file f / \"f_" strftime("%Y-%m-%d_%H.%M.%S") ".txt\"/" }
$offecho
$call "awk -f createfile.awk > ftime.inc"
$include ftime.inc
put f "hello"/;
For more info on AWK see gawk.htmlfile f / "f_2008-05-16_14.28.59.txt"/
No comments:
Post a Comment