|
From: Boniforti F. <fl...@pi...> - 2009-11-23 12:57:17
|
Hello everybody, I'm still trying to make successfull use of variables in my gnuplot script, so I'm asking how it would be possible to do a "set xrange" using a variable. I have following variables: FIRST_DAY=`date -d "-$(($(date +%d)-1)) days" +%Y-%m-%d` LAST_DAY=`date -d "+1 month -$(date +%d) days" +%Y-%m-%d` What I need to achieve is to set xrange in between the above two values. Today it should give: set xrange = [2009-11-01:2009-11-30] I tried with set xrange = [FIRST_DAY:LAST_DAY] but it doesn't work. Any help will be appreciated! Thanks, Flavio Boniforti PIRAMIDE INFORMATICA SAGL Via Ballerini 21 6600 Locarno Switzerland Phone: +41 91 751 68 81 Fax: +41 91 751 69 14 URL: http://www.piramide.ch E-mail: fl...@pi... |
|
From: Boniforti F. <fl...@pi...> - 2009-11-23 13:26:26
|
> FIRST_DAY=`date -d "-$(($(date +%d)-1)) days" +%Y-%m-%d` > LAST_DAY=`date -d "+1 month -$(date +%d) days" +%Y-%m-%d` I just discovered that it doesn't assign correctly the value I want, in gnuplot: gnuplot> FIRST_DAY=`date -d "-$(($(date +%d)-1)) days" +%Y-%m-%d` gnuplot> print FIRST_DAY 1997 While at the usual bash prompt I get: storebox:~# date -d "-$(($(date +%d)-1)) days" +%Y-%m-%d 2009-11-01 How come? Thanks, Flavio Boniforti PIRAMIDE INFORMATICA SAGL Via Ballerini 21 6600 Locarno Switzerland Phone: +41 91 751 68 81 Fax: +41 91 751 69 14 URL: http://www.piramide.ch E-mail: fl...@pi... |
|
From: Thomas S. <t.s...@fz...> - 2009-11-23 14:40:12
|
you get what you request ;-)
`date -d "-$(($(date +%d)-1)) days" +%Y-%m-%d`
gives
2009-11-01
and
FIRST_DAY=2009-11-01
is
2009 - 11 - 1 = 1997
you need to make clear that you expect a string:
FIRST_DAY=system('date -d "-$(($(date +%d)-1)) days" +%Y-%m-%d')
FIRST_DAY="`date -d "-$(($(date +%d)-1)) days" +%Y-%m-%d`"
FlavioB wrote:
>
>> FIRST_DAY=`date -d "-$(($(date +%d)-1)) days" +%Y-%m-%d`
>> LAST_DAY=`date -d "+1 month -$(date +%d) days" +%Y-%m-%d`
>
> I just discovered that it doesn't assign correctly the value I want, in
> gnuplot:
>
> gnuplot> FIRST_DAY=`date -d "-$(($(date +%d)-1)) days" +%Y-%m-%d`
> gnuplot> print FIRST_DAY
> 1997
>
> While at the usual bash prompt I get:
>
> storebox:~# date -d "-$(($(date +%d)-1)) days" +%Y-%m-%d
> 2009-11-01
>
> How come?
>
> Thanks,
> Flavio Boniforti
>
> PIRAMIDE INFORMATICA SAGL
> Via Ballerini 21
> 6600 Locarno
> Switzerland
> Phone: +41 91 751 68 81
> Fax: +41 91 751 69 14
> URL: http://www.piramide.ch
> E-mail: fl...@pi...
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Gnuplot-info mailing list
> Gnu...@li...
> https://lists.sourceforge.net/lists/listinfo/gnuplot-info
>
>
--
View this message in context: http://old.nabble.com/set-xrange-from-variable-tp26477602p26479233.html
Sent from the Gnuplot - User mailing list archive at Nabble.com.
|
|
From: Boniforti F. <fl...@pi...> - 2009-11-23 14:59:35
|
Hallo Thomas,
> you get what you request ;-)
That's for sure, as we're talking about computers ;-)
> `date -d "-$(($(date +%d)-1)) days" +%Y-%m-%d` gives
> 2009-11-01
Can you correct me if I'm wrong? It give 2009-11-01 because it evaluates
the first piece of code up to "%Y"? And then it takes "-%m" and "-%d" as
single numerical values?
[cut]
> you need to make clear that you expect a string:
> FIRST_DAY=system('date -d "-$(($(date +%d)-1)) days"
> +%Y-%m-%d') FIRST_DAY="`date -d "-$(($(date +%d)-1)) days" +%Y-%m-%d`"
Many many thanks, but as I'm curious and willing to learn some more:
what's the "system" word standing for?
And how do I use double-quotes and/or single-quotes (like in your second
example)?
Thanks again and kind regards,
Flavio Boniforti
PIRAMIDE INFORMATICA SAGL
Via Ballerini 21
6600 Locarno
Switzerland
Phone: +41 91 751 68 81
Fax: +41 91 751 69 14
URL: http://www.piramide.ch
E-mail: fl...@pi...
|
|
From: Thomas S. <t.s...@fz...> - 2009-11-23 16:46:27
|
FlavioB wrote:
>
> ...
> Can you correct me if I'm wrong? It give 2009-11-01 because it evaluates
> the first piece of code up to "%Y"? And then it takes "-%m" and "-%d" as
> single numerical values?
>
yes, and takes 2009-11-01 as a request to calculate the result.
and it will give an error message when %d is 07, 08, or 09
(because 0x is interpreted as an octal number).
FlavioB wrote:
>
>> you need to make clear that you expect a string:
>> FIRST_DAY=system('date -d "-$(($(date +%d)-1)) days"
>> +%Y-%m-%d')
>> FIRST_DAY="`date -d "-$(($(date +%d)-1)) days" +%Y-%m-%d`"
>
> Many many thanks, but as I'm curious and willing to learn some more:
> what's the "system" word standing for?
>
http://www.gnuplot.info/docs/node336.html
http://www.gnuplot.info/docs/node327.html
FlavioB wrote:
>
> And how do I use double-quotes and/or single-quotes
> (like in your second example)?
>
that's not so easy...
the outer double quotes are needed to make clear that the
result of the 'date' command is a string:
print `date -d "-$(($(date +%d)-1)) days" +%Y-%m-%d`
1997
print "`date -d "-$(($(date +%d)-1)) days" +%Y-%m-%d`"
2009-11-01
single quotes would not work here, because then the backquotes
would not be interpreted (by gnuplot):
print '`date -d "-$(($(date +%d)-1)) days" +%Y-%m-%d`'
`date -d "-$(($(date +%d)-1)) days" +%Y-%m-%d`
the double quotes inside the backquotes are essential, single
quotes would work here (due to the expansions the shell
does):
print "`date -d '-$(($(date +%d)-1)) days' +%Y-%m-%d`"
date: invalid date `-$(($(date +%d)-1)) days'
obviously, the double quotes inside the backquotes are not
interpreted as string delimiters by gnuplot, otherwise the
string would end in between.
FlavioB wrote:
>
> Thanks again and kind regards,
> Flavio Boniforti
>
> PIRAMIDE INFORMATICA SAGL
> Via Ballerini 21
> 6600 Locarno
> Switzerland
> Phone: +41 91 751 68 81
> Fax: +41 91 751 69 14
> URL: http://www.piramide.ch
> E-mail: fl...@pi...
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Gnuplot-info mailing list
> Gnu...@li...
> https://lists.sourceforge.net/lists/listinfo/gnuplot-info
>
>
--
View this message in context: http://old.nabble.com/set-xrange-from-variable-tp26477602p26481739.html
Sent from the Gnuplot - User mailing list archive at Nabble.com.
|
|
From: Steve C. <sc...@ja...> - 2009-11-24 15:42:25
|
07 is not valid octal? Thomas Sefzick wrote: > and it will give an error message when %d is 07, 08, or 09 > (because 0x is interpreted as an octal number). > > |
|
From: Thomas S. <t.s...@fz...> - 2009-11-24 16:41:43
|
oh, sorry, that's a mistake, 07 *is* a valid octal stevecoh1 wrote: > > 07 is not valid octal? > > Thomas Sefzick wrote: >> and it will give an error message when %d is 07, 08, or 09 >> (because 0x is interpreted as an octal number). >> >> > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Gnuplot-info mailing list > Gnu...@li... > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > > -- View this message in context: http://old.nabble.com/set-xrange-from-variable-tp26477602p26498554.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |