Mercurial > hg > octave-lyh
changeset 9461:ff8d7f3ad203
gnuplot_binary.m: accept arguments in addition to program name
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 24 Jul 2009 17:41:09 -0400 |
parents | 1fddcf651559 |
children | 44e2e568f973 |
files | scripts/ChangeLog scripts/plot/__gnuplot_open_stream__.m scripts/plot/gnuplot_binary.in |
diffstat | 3 files changed, 29 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2009-07-24 John W. Eaton <jwe@octave.org> + + * plot/gnuplot_binary.in: Accept arguments in addition to program name. + * plot/__gnuplot_open_stream__.m: Pass additional args to gnuplot. + 2009-07-23 Ben Abbott <bpabbott@mac.com> * plot/legend.m: Add an hggroup demo using bar(). Include clf()
--- a/scripts/plot/__gnuplot_open_stream__.m +++ b/scripts/plot/__gnuplot_open_stream__.m @@ -23,14 +23,14 @@ ## Created: 2009-04-11 function plot_stream = __gnuplot_open_stream__ (npipes, h) - cmd = gnuplot_binary (); + [prog, args] = gnuplot_binary (); if (npipes > 1) - [plot_stream(1), plot_stream(2), pid] = popen2 (cmd); + [plot_stream(1), plot_stream(2), pid] = popen2 (prog, args{:}); if (pid < 0) error ("__gnuplot_open_stream__: failed to open connection to gnuplot."); endif else - plot_stream = popen (cmd, "w"); + plot_stream = popen (sprintf ("%s ", prog, args{:}), "w"); if (plot_stream < 0) error ("__gnuplot_open_stream__: failed to open connection to gnuplot."); endif
--- a/scripts/plot/gnuplot_binary.in +++ b/scripts/plot/gnuplot_binary.in @@ -17,34 +17,44 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Loadable Function} {@var{val} =} gnuplot_binary () -## @deftypefnx {Loadable Function} {@var{old_val} =} gnuplot_binary (@var{new_val}) -## Query or set the name of the program invoked by the plot command. +## @deftypefn {Loadable Function} {[@var{prog}, @var{args}] =} gnuplot_binary () +## @deftypefnx {Loadable Function} {[@var{old_prog}, @var{old_args}] =} gnuplot_binary (@var{new_prog}, @varg{arg1}, @dots{}) +## Query or set the name of the program invoked by the plot command +## and any arguments to pass to it. Previous arguments are returned +## as a cell array. ## The default value @code{\"gnuplot\"}. @xref{Installation}. ## @end deftypefn ## Author: jwe -function retval = gnuplot_binary (new_val) +function [prog, args] = gnuplot_binary (new_prog, varargin) persistent gp_binary = %OCTAVE_CONF_GNUPLOT%; + persistent gp_args = {}; if (nargout > 0 || nargin == 0) - retval = gp_binary; + prog = gp_binary; + args = gp_args; endif if (nargin == 1) - if (ischar (new_val)) - if (! isempty (new_val)) - gp_binary = new_val; + if (ischar (new_prog)) + if (! isempty (new_prog)) + gp_binary = new_prog; else error ("gnuplot_binary: value must not be empty"); endif else - error ("gnuplot_binary: expecting arg to be a character string"); + error ("gnuplot_binary: expecting program to be a character string"); endif - elseif (nargin > 1) - print_usage (); + endif + + if (nargin > 1) + if (iscellstr (varargin)) + gp_args = varargin; + else + error ("gnuplot_binary: expecting arguments to be character strings"); + endif endif endfunction