function Value = get(RespObj,Property)
%GET  Access/query Response Object property values.
%
%   VALUE = GET(RespObj,'Property') returns the value of the 
%   specified property of the Response Object RespObj.
%
%   GET(RespObj) displays all Response Object properties
%   and their values.
%
%   See also SET

%   AllValues = GET(RespObj,'Undocumented') returns a structure 
%   with all the documented and undocumented response properties.  
%   This is used in some of the response object functions to get  
%   all the properties, while exposing only the immediately useful 
%   properties to the user.

%   P. Gahinet
%   Copyright 1986-2000 The MathWorks, Inc. 
%   $Revision: 1.11 $ 

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

if ni==1 | (ni==2 & strncmpi(Property,'undoc',5)),
   if ni==1,
      % List of documented property values
      [AllProps,junk,Doc] = pnames(RespObj);
      AllValues = pvget(RespObj);
      List = cell2struct(AllValues(Doc),AllProps(Doc),1);
   else
      % Values of all undocumented properties
      List = cell2struct(pvget(RespObj),pnames(RespObj),1);
   end
   if nargout,
      Value = List;
   else
      disp(' '), disp(List)
   end
   
else 
   % GET(RespObj,'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
   
   % Get the names of all public properties (including parent properties)
   AllProps = pnames(RespObj);
   
   % Identify queried properties 
   Nq = prod(size(Property));
   Value = cell(1,Nq);
   for i=1:Nq,
      % Find matches for k-th property name
      % RE: Must include all properties to detect multiple hits
      try
         Value{i} = pvget(RespObj,pnmatch(Property{i},AllProps));
      catch
         error(lasterr)
      end
   end
   
   % Strip cell header if PROPERTY was a string
   if CharProp,
      Value = Value{1};
   end
end
