# HG changeset patch # User Ben Abbott # Date 1204315307 18000 # Node ID 04426cffcf41b42c437e353a681a41f42086012a # Parent b84c5cbc081243fabec4026636f0c947c587c372 print.m: Figure handle as argument. diff -r b84c5cbc0812 -r 04426cffcf41 scripts/ChangeLog --- a/scripts/ChangeLog Fri Feb 29 04:09:03 2008 -0500 +++ b/scripts/ChangeLog Fri Feb 29 15:01:47 2008 -0500 @@ -1,3 +1,7 @@ 2008-02-29 John W. Eaton + + * plot/print.m: Modified to accept a figure handle as an optional input. + 2008-02-29 John W. Eaton * plot/print.m: Handle gif and jpg devices. diff -r b84c5cbc0812 -r 04426cffcf41 scripts/plot/print.m --- a/scripts/plot/print.m Fri Feb 29 04:09:03 2008 -0500 +++ b/scripts/plot/print.m Fri Feb 29 15:01:47 2008 -0500 @@ -19,10 +19,14 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} print (@var{filename}, @var{options}) +## @deftypefnx {Function File} {} print (@var{h}, @var{filename}, @var{options}) ## Print a graph, or save it to a file ## ## @var{filename} defines the file name of the output file. If no ## filename is specified, output is sent to the printer. +## +## @var{h} specifies the figure handle. If no handle is specified +## the handle for the current figure is used. ## ## @var{options}: ## @table @code @@ -138,6 +142,7 @@ function print (varargin) debug = false; debug_file = "octave-print-commands.log"; special_flag = "textnormal"; + old_fig = []; ## Ensure the last figure is on the screen for single line commands like ## plot(...); print(...); @@ -184,8 +189,11 @@ function print (varargin) elseif (length (arg) > 0) name = arg; endif + elseif (ishandle (arg)) + old_fig = gcf (); + figure (arg); else - error ("print: expects string options"); + error ("print: inputs must be string options, or a figure handle."); endif endfor @@ -431,4 +439,8 @@ function print (varargin) unlink (printname); endif + if (ishandle (old_fig)) + figure (old_fig) + endif + endfunction