Procedures in Gnuplot

function, gnuplot, procedure

Solution

Gnuplot supports (simple) functions with arguments:

func1(x)=x."string2"

More complicated "inline" functions can be created if you're using gnuplot 4.4:

func1(x)=(var1=x, var2=var1."string2", var1.var2)  #returns x.x."string2"

In this form, the last portion of the function is what is returned (`var1.var2`) and the statements are evaluated left to right.

If you want to have functions which accept no parameters, you can (often) use macros:

set macro
funcmacro='"string1"."string2"'
print @funcmacro

Problem

Is there a way to have procedures (or C-like functions) in Gnuplot? I need something really simple, just something like: ``` function func1() { var1 = "string1"; var2 = var1."string2"; return var2; } ``` to make my gnuplot scripts a little bit more compact.

Original source