|
From: Ethan M. <merritt@u.washington.edu> - 2005-03-07 22:45:55
|
Juergen Wieferink wrote (apropos RFE 1108413):
> The proper syntax would be a string function
> "command('blabla1')" returning the standard output as a
> string (as suggested by Petr in October 2004). I still think
> this would be a useful feature.
The suggestion from the previous discussion was:
> > On Friday 15 October 2004 12:01 am, Petr Mikulik wrote:
>
> >> I would propose to ignore macro expansion in `blabla1` and !blabla2
> >> but allow them in system('blabla2') and in value = execute('blabla1');
>
> >> Where the execute() is a new command. The user could use what he
> >> wants.
The syntax command(`blabla`) is difficult to implement in gnuplot's
parser, because it will try evaluate the contents of the parantheses
before recognizing the particular function being called. This just
pushes back the original problem by one layer of function call.
There may be a way around this, but so far I haven't been able to see it.
What I *can* see how to do easily is to distinguish between
single back-quotes and double back-quotes. The system command would be
executed in either case. The single back-quote case would then
return the output directly into the gnuplot input line, just as it does
now. The double back-quote case would also return the output into
the gnuplot input line, but it would wrap it in double quotes.
This makes it suitable for string variable assignment.
This is implemented by the attached patch.
gnuplot> numvar = `uname -mo`
undefined variable: i686
gnuplot> stringvar = ``uname -mo``
gnuplot> show var
Variables:
pi = 3.14159265358979
stringvar = i686 GNU/Linux
What do you think. Can we live with this syntax?
--
Ethan A Merritt merritt@u.washington.edu
Biomolecular Structure Center
Mailstop 357742
University of Washington, Seattle, WA 98195
|