function Value = get(ViewerObj,Property)
%GET  Access/query LTI Viewer Object property values.
%
%   VALUE = GET(ViewerObj,'Property') returns the value of the specified
%   property of the LTI Viewer Object ViewerObj.
%
%   See also SET.

%   Copyright 1986-2000 The MathWorks, Inc. 
%   $Revision: 1.9 $  $Date: 2000/06/14 20:03:11 $

ni = nargin;
error(nargchk(1,2,ni));

% Get all properties and their values
AllValues = struct2cell(ViewerObj);
AllProps = fieldnames(ViewerObj);

% Handle various cases
if ni==1
   List = cell2struct(AllValues,AllProps,1);
   if nargout
      Value = List;
   else
      disp(' '), disp(List)
   end

else
   % GET(ViewerObj,'Property')
   CharProp = ischar(Property);
   if CharProp
      Property = {Property};
   elseif ~iscellstr(Property)
      error('Property name must be a string or a cell vector of strings.')
   end

   % Identify queried properties
   Nq = prod(size(Property));
   Queries = zeros(1,Nq);
   for i=1:Nq
      % Find matches for k-th property name
      % RE: Must include all properties to detect multiple hits
      try
         [junk,Queries(i)] = pnmatch(Property{i},AllProps);
      catch
         error(lasterr)
      end
   end

   % Get their values
   Value = AllValues(Queries).';

   % Strip cell header if PROPERTY was a string
   if CharProp
      Value = Value{1};
   end

end
