function B = validatehandles(B)
%VALIDATEHANDLES  prune invalid scribehandle items from a list

%   Copyright 1984-2000 The MathWorks, Inc. 
%   $Revision: 1.4 $  $Date: 2000/06/01 02:52:45 $

if ~isempty(B)
   %HGHandles = B.HGHandle;
   HGHandles = subsref(B,substruct('.','HGHandle'));
   if iscell(HGHandles)
      HGHandles = [HGHandles{:}];
   end
   B = B(find(ishandle(HGHandles)));            
end
