gnuplot 命令行参数和调用参数

gnuplot command line arguments and call arguments

跟进 the question on SO about command line parameters to gnuplot scripts 及其相应的答案,我看到我可以制作一个脚本 myscript.gp 就像

if(!exist("parameters")) parameters=""
plot "< myprog ".parameters u 1:2

并用

调用它
$ gnuplot -e "parameters='-m 5'" myscript.gp

但是,当 运行 在交互模式下与 myscript2.gp as

时,我可以获得类似的结果
parameters="[=12=]"
plot "< myprog ".parameters u 1:2

并从交互式提示中将其调用为

gnuplot> call "myscript2.gp" "-m 5"

现在是问题。正如我所看到的,这两种方法没有连接,当 运行 批量时 $O 会失败,而 'parameters' 在使用 call.

时不会更新

如何设置可以从 shell 命令行 以及 从 gnuplot 交互式命令行调用的脚本?另一种方式问它,是否可以测试调用脚本的条件?

谢谢,

四处游玩,我发现了一个相当不雅的解决方案,但这可能有助于实现我想要的。

parameters=""                                  # sets default value
if ("$#" eq sprintf("%d",1)) parameters="[=10=]"   # if using call with 1 parameter: $#=1
if (exist("bpar")) parameters=bpar             # checking for batch call

plot "< myprog ".parameters u 1:2

然后可以通过

调用
$ gnuplot -e "bpar='-m 5'" myscript.gp

gnuplot> call "myscript2.gp" "-m 5"