Get the date to have a log_file name containing the date

19 views
Skip to first unread message

Benoît Martin

unread,
Jul 6, 2016, 11:05:32 AM7/6/16
to AMPL Modeling Language
Hello,

I am using the following command to save my node log in a txt file.
option log_file foo.txt;
I would like to automatically name the txt file with the date. Is it possible to do that in Ampl?

Thanks

Benoît

Robert Fourer

unread,
Jul 10, 2016, 2:48:49 AM7/10/16
to am...@googlegroups.com
The following string expression evaluates to a fixed filename followed by the current date:

ampl: print "foo" & substr(date(),1,8) & ".txt";
foo20160710.txt

You can use this expression in an option statement, as long as you put parentheses around it so that AMPL can recognize that it is an expression:

ampl: option log_file ("foo" & substr(date(),1,8) & ".txt");

ampl: option log_file;
option log_file foo20160710.txt;

Bob Fourer
am...@googlegroups.com

=======

Abdulaziz Alghosh

unread,
Apr 28, 2017, 7:50:55 AM4/28/17
to AMPL Modeling Language, 4...@ampl.com

Hi Robert,

i am trying doing so but AMPL shows always an error saying "date is not defined". May you tell me if you encountered such an error ...

Br
Abdul
Reply all
Reply to author
Forward
0 new messages