|
From: sfeam (E. Merritt) <eam...@gm...> - 2011-04-01 05:05:00
|
On Thursday, March 31, 2011, Arun Persaud wrote:
>
> is there a way then that I can do things like
>
> set macros
> f(s)=sprintf("m=%s_m",s)
> g(x)=m*x
>
> t1_m = 1.0
> t2_m = 2.0
>
> A=f("t1")
> B=f("t2")
>
> plot @A,g(x),@B,g(x)
>
> without using macros?
I'm not clear on the significance of using A and B
as opposed to directly calling f(). Is the variant
below useful?
f(var) = value(var . "_m")
g(x) = m*x
plot m=f("t1"),g(x), m=f("t2"),g(x)
> Here is some addition for the manual (output of cvs diff -u)
Thanks.
> -----------------start-------------------------------
>
> RCS file: /cvsroot/gnuplot/gnuplot/docs/gnuplot.doc,v
> retrieving revision 1.658
> diff -u -r1.658 gnuplot.doc
> --- gnuplot.doc 26 Mar 2011 02:39:44 -0000 1.658
> +++ gnuplot.doc 1 Apr 2011 04:07:32 -0000
> @@ -2584,6 +2584,18 @@
> Macro expansion does not occur inside either single or double quotes.
> However macro expansion does occur inside backquotes.
>
> + Macro expansion is also handled as the very first thing the
> + interpreter does when looking at a new line of commands and is only
> + done once. Therefore, code like the following will execute correctly:
> +
> + A = "c=1"
> + @A
> +
> + but this line will not, since the macro is defined on the same line
> + and can't be expanded in time
> +
> + A = "c=1"; @A # will not expand to c=1
> +
> For execution of complete commands the `evaluate` command may also be
> handy.
> 3 String variables, macros, and command line substitution
> ?mixing_macros_backquotes
>
> -------------------end----------------------
>
> Thanks for the quick help
>
> Arun
>
>
|