From: Hans-Bernhard B. <br...@ph...> - 2004-07-09 09:09:55
|
On Thu, 8 Jul 2004, Ethan Merritt wrote: > Or did you mean > > set label 1 sprintf( "After fitting, A = %3.2f, B = %3.2f", A, B) That one, mostly. Generally, the "A = $A" syntax may seem simple, but it's also of rather limited flexibility. This function-like syntax also extends more naturally to other operations on strings (scanning a string, reading a string from an external file, ...). I think we can take a hint from Java, here: Strings are native datatypes, but the only operator they support is '+' for concatenation. Everything else is done by functions. > But I don't really see how either of these would work on the > command line. The existing "userstrings" patch allows > > STYLE1 = "1:4 with lines lw 2" > plot 'datafile' using $STYLE1 In this context, the decision about $ vs. sprintf() would affect only the first of these lines. In my scheme, it might become: STYLE1 = sprintf("1:%d with lines lw %g", i, width) We should probably foresee an interface to gprintf(), too, to give access to %l/%L from 'help format spec'. > Admittedly the userstrings patch would probably better be > described as implementing macro definitions rather string variables, Exactly. Just storing a fixed string in a variable is not very helpful. The real power to be gained would lie in the methods for constructing such strings from other elements. Compare it to our user-defined variables. They would be of rather limited applicability if you couldn't use arbitrary expressions to compute their value. > > $ already being used for at > > least two entirely unrelated things in gnuplot > > The primary use is for column numbers. > The second use I know about is for the command line > variables ($1, $2, $3...). IIRC there's a feature request that we should $-expand environment variables. And TeX strings have to be able to contain literal $ characters. And your own suggestions just introduced two independent uses of it: to signal a string variable / macro to be expanded, and to signal a number to be inserted inside a string. -- Hans-Bernhard Broeker (br...@ph...) Even if all the snow were burnt, ashes would remain. |