# HG changeset patch # User Rik # Date 1375334887 25200 # Node ID 327862500f1c66f921cedc47c48bd5cb67d56e25 # Parent 9d9fe4361870577bd77f875f5873ec7176a12d12 ishold.m: Recode to follow modern Octave coding conventions. * scripts/plot/ishold.m: Put input validation first. Change error messages to reference bad input variable by name. Don't use unnecessary strcmpi when strcmp will work. diff -r 9d9fe4361870 -r 327862500f1c scripts/plot/ishold.m --- a/scripts/plot/ishold.m Wed Jul 31 22:13:47 2013 -0700 +++ b/scripts/plot/ishold.m Wed Jul 31 22:28:07 2013 -0700 @@ -30,29 +30,31 @@ function retval = ishold (h) + if (nargin > 1) + print_usage (); + endif + if (nargin == 0) fig = gcf (); ax = get (fig, "currentaxes"); - elseif (nargin == 1) + else if (ishandle (h)) - if (isfigure (h)) - ax = get (h, "currentaxes"); + if (strcmp (get (h, "type"), "figure")) fig = h; - elseif (strcmpi (get (h, "type"), "axes")) + ax = get (fig, "currentaxes"); + elseif (strcmp (get (h, "type"), "axes")) ax = h; - fig = get (h, "parent"); + fig = get (ax, "parent"); else - error ("ishold: expecting argument to be axes or figure graphics handle"); + error ("ishold: H must be an axes or figure graphics handle"); endif else - error ("ishold: expecting argument to be axes or figure graphics handle"); + error ("ishold: H must be an axes or figure graphics handle"); endif - else - print_usage (); endif - retval = (strcmpi (get (fig, "nextplot"), "add") - && ! isempty (ax) && strcmpi (get (ax, "nextplot"), "add")); + retval = (strcmp (get (fig, "nextplot"), "add") + && ! isempty (ax) && strcmp (get (ax, "nextplot"), "add")); endfunction