|
From: sfeam <sf...@us...> - 2014-05-21 14:56:45
|
On Wednesday, 21 May 2014 12:11:29 AM atoms.h wrote:
> Thanks Ethan for your quick reply!
>
> One problem is that I have to use the macro for
> $ `echo $(awk '/Total/ {print $4}' @file)`
> otherwise i cannot pass the variable to bash.
Break it down into steps:
awkcommand = "awk '/Total/ {print $4}' ".file
system( "echo $(" . awkcommand . ")" )
or something like that.
> What also doesn't work (and I have no idea as to why that is) is to do
> $ `echo $(awk '/Total/ {print $4}' @item(i))`
It seems you misunderstand what a macro is in gnuplot.
It is not some kind of function that is executed in-line.
Gnuplot macros do not take parameters.
They are basically a text-substitution mechanism that operates
before the command is executed. Think of it as running a
search-and-replace operation in a text editor before
feeding the result to gnuplot. The editor has no idea about
gnuplot syntax like do loops or if statements - it applies
the search-and-replace everywhere.
> Then I get error because of the brackets....
>
> Secondly, I realize that this probably wasn't the best example for what I
> actually want to do.
> Because 'total' gets overwritten for every file. My real goal would be
> something like
> $ total(i) = sprintf("%d",`echo $(awk '/Total/ {print $4}' @file)`)
> So store the values in a fake-array....
Sorry, gnuplot doesn't have arrays.
But it does have functions, so if your total() function can be
evaluated at the time it is used then your command above might
be close to working.
Ethan
|