

And double quotes do not block backquote substitution, so mycomputer = "`uname -n`" Results in the number of lines in mydata.inp being stored in the integer variable lines. Backquotes do not block macro substitution, so filename = "mydata.inp" lines = ` wc -lines | sed "s/. String variables, macros, and command line substitutionThe interaction of string variables, backquotes and macro substitution is somewhat complicated. will always act as the original value of A even if A itself is reassigned inside the loop.įor execution of complete commands the evaluate command may also be handy. Macro expansion inside a bracketed iteration occurs before the loop is executed i.e.

#GNUPLOT COMMANDS CODE#
Therefore, code like the following will execute correctly: A = this line will not, since the macro is defined on the same line and will not be expanded in time A = "c=1" # will not expand to c=1

Macro expansion is handled as the very first thing the interpreter does when looking at a new line of commands and is only done once.

However macro expansion does occur inside backquotes. The following example checks that C can safely be expanded as the name of a user-defined variable: C = "pi" if ( exists(C)) print C, " = ", expansion does not occur inside either single or double quotes. The function exists() may be useful in connection with macro evaluation. "bar" using 1: 5 with points lt 3 pt 5 ps 2
#GNUPLOT COMMANDS FULL#
Plot "foo" with "bar" with line containing symbols is expanded on input, so that by the time it is executed the effect is identical to having typed in full plot "foo" using 1: 3 with lines lt 4 lw 2, \ Only string constants may be expanded using this mechanism, not string-valued expressions. This allows string variables to be used as command line macros. The text in the string variable may contain any number of lexical elements. Set timestamp "generated on %Y-%m-%d by `whoami`" Substitution of string variables as macrosThe character is used to trigger substitution of the current value of a string variable into the command line. These will generate labels with the current time and userid: set label "generated on `date +%Y-%m-%d` by `whoami`" at 1, 1 This will run the program leastsq and replace leastsq (including backquotes) on the command line with its output: f(x) = `leastsq` This change brings backquote substitution in line with the system() function.Ĭommand-line substitution can be used anywhere on the gnuplot command line except inside strings delimited by single quotes. Exit status of the system command is returned in variables GPVAL_SYSTEM_ERRNO and GPVAL_SYSTEM_ERRMSG.ĬHANGE (differs from versions 4 through 5.2): Internal carriage-return (' \r') and newline (' \n') characters are not stripped from the input stream during substitution. This command is spawned and the output it produces replaces the backquoted text on the command line. Substitution of system commands in backquotesCommand-line substitution is specified by a system command enclosed in backquotes. These are triggered by the presence of text in backquotes (ascii character 96) or preceded by (ascii character 64). before it is interpreted or executed, two forms of lexical substitution are performed. Substitution and Command line macrosWhen a command line to gnuplot is first read, i.e.
