[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gnuplot-info-beta
Subject:    Re: if (1) b="plot x*x"; @b
From:       Petr Mikulik <mikulik () physics ! muni ! cz>
Date:       2009-02-06 17:48:47
Message-ID: Pine.LNX.4.64.0902061842440.16750 () monoceros ! physics ! muni ! cz
[Download RAW message or body]

> > There is a strange error happening with a not-yet-used variable:
> > 
> > gnuplot> load 'bug.gp'
> >          "bug.gp", line 4: warning: b is not a string variable
> > 
> > where bug.gp:
> > 
> > set macros
> > a=''
> > if (1) a="plot x"; @a
> > if (1) b="plot x*x"; @b
> 
> This has always been a limitation on the use of macros.
> The substitution is done for each whole line as the line
> is read in, before any of the commands on that line have
> been executed.  

I see; a better demonstration of this effect it rather this one:

set macros
a='print 789'
if (1) a="print 123"; @a
if (1) b="print 456"; @b

The solution seems to be:

set macros
if (1) b="print 999"
if (1) @b


> For most purposes, the use of macros has been entirely supplanted
> by string variables. In the case above:
> 
>  if (1) a="plot x";  evaluate(a)

Thanks for this hint, it works fine in gnuplot-cvs.
Finally I had to use the construct with macros because the script had to run 
on gnuplot 4.2.x.

---
PM

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic