From: Juhász P. <pet...@gm...> - 2012-01-31 19:02:32
|
On Tue, 2012-01-31 at 18:18 +0100, pl...@pi... wrote: > Hi, > > I have a number of gnuplot scripts that have various options set. I > would like to set a default value in the script and optionally determine > the value from the calling script or command. > > This does not seem to be possible. > > eg. > > if (doPNG) { set terminal png; set output pngfile} > else { set terminal wxt } > > plot .... > > > called as : > > (echo 'doPNG=1;' && cat cos_fit.gnu) | gnuplot > > > Some kind of isdefined() function would be a solution or simply if the > interpreter could return some kind of NaN value that could then be > tested instead of triggering an error and breaking out. > > Alternatively kind of error trapping mechanism but that may be going > beyond what is needed for this simple test. > > Do you think this would be a useful feature? > > Regards,. Peter. > It's such a useful feature that it has been implemented already: if (exists("doPNG")) { # whatever... Look at "help exists". You'll see that, well, help exists. (Sorry, I couldn't resist...) There is also "defined", but that's deprecated. Péter Juhász |