1

I tried passing variables to a gnuplot script as explained here, but I only get an error message:

Non-numeric string found where a numeric expression was expected

I am using gnuplot on Windows 7. I had a friend try the same thing on Linux Mint and it works like a charm there.

Is this functionality just not included in the windows version of gnuplot or can I change something to accomplish the same thing? Is there another way to do this?


My script:

print "p0=$0 p1=$1 p2=$2 p3=$3 p4=$4 p5=$5 p6=$6 p7=x$7x"

How i call it:

gnuplot> call 'calltest.gp' "abcd" 1.2 + "'quoted'" -- "$2"

I use gnuplot Version 5.0 patchlevel 0.

0

1 Answer 1

1

The parameters to call must be strings. While conversion of numbers to strings works on Linux, it makes problems on Windows:

Wrong:

call 'script.gp' 'string' 12

Correct:

call 'script.gp' 'string' '12'

You must also note, that the call behavior was changed with version 5. Now, ARG0 contains the naming of the called script, and the parameters are contained in variables ARG1, ARG2 etc.

Sign up to request clarification or add additional context in comments.

4 Comments

Well, this does eliminate the error message. However, the substitution of $0 etc. still doesn't work (I just get the unsubstituted string).
That was just a guess, since you don't provide any code showing what you are actually doing! And the gnuplot version you are using is also interesting (in gnuplot 5 several things changed). The documentation you linked is btw quite outdated, it refers to 3.7, whereas the current version is 5
Ah, that's it! I am using version 5.0 but didn't know about the new style substitution (ARG0, etc.). Mind making this a separate answer, so I can accept it?
I edited the answer, since the first part refers to the error message you posted. The other thing with the different style of call in gnuplot 5 is, at first sight completely unrelated to your actual problem, since you don't show any code... Even if your problem is solved now, could you please include a code snippet of how you called the script and how you used the call parameters? Otherwise your question is quite useless for anyone else than you and should be closed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.