function theResult = IsPX(theItem)

% IsPX -- Is the item a PXObject or PXReference?
%  IsPX(x) returns 1 if theItem is a PXObject,
%   2 if it is a PXReference, and 3 if it is
%   a PXStruct.  Otherwise, a value of 0 is
%   returned.
 
% Copyright (C) 1997 Dr. Charles R. Denham, ZYDECO.
%  All Rights Reserved.
%   Disclosure without explicit written consent from the
%    copyright owner does not constitute publication.
 
% Version of 09-Apr-1997 10:56:16.

if nargin < 1, help(mfilename), return, end

theClass = class(theItem);
switch theClass
case 'struct'
   result = 0;
   theObject = eval('theItem.itsObject', '[]');
   if ispx(theObject), result = 3; end
case 'double'
   result = 0;
   if ishandle(theItem)
      if ispx(get(theItem, 'UserData'))
         result = 2;
      end
   end
otherwise
   result = isa(theItem, 'px');
end

if nargout > 0
   theResult = result;
  else
   disp(result)
end
