home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / GRAPHICS.DI$ / CLOSE.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  771 b   |  40 lines

  1. function close(h)
  2. %CLOSE    Close specified window.
  3. %    CLOSE(H) closes the window with handle H.
  4. %    CLOSE, by itself, closes the current figure window.
  5. %
  6. %    CLOSE closes the window unconditionally and without
  7. %    confirmation.
  8. %
  9. %    CLOSE('name') closes the named window.
  10. %
  11. %    See also DELETE.
  12.  
  13. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  14. %    J.N. Little 1-7-92
  15.  
  16. if nargin == 0
  17.         h = get(0,'Children');
  18.         if ~isempty(h)
  19.            h = gcf;
  20.         else
  21.            return
  22.         end
  23. end
  24. if isstr(h)
  25.     % It is a name, convert to handle
  26.     hlist = get(0,'children');
  27.     id = 0;
  28.     for i=hlist
  29.         if strcmp(h,get(i,'name'))
  30.             delete(i)
  31.             id = 1;
  32.         end
  33.     end
  34.     if id == 0
  35.         error('Specified window does not exist.');
  36.     end
  37. else
  38.     delete(h)
  39. end
  40.