function varargout = adddynprop(h, name, datatype, setfcn, getfcn)
%ADDDYNPROP   Add a dynamic property
%   ADDDYNPROP(H, NAME, TYPE)  Add the dynamic property with NAME and
%   datatype TYPE to the object H.
%
%   ADDDYNPROP(H, NAME, TYPE, SETFCN, GETFCN)  Add the dynamic property and
%   setup PostSet and PreGet listeners with the functions SETFCN and GETFCN.

%   Author(s): J. Schickler
%   Copyright 1988-2004 The MathWorks, Inc.
%   $Revision: 1.1.6.5 $  $Date: 2004/06/06 17:07:10 $

error(nargchk(3,5,nargin));

if nargin < 5
    getfcn = [];
    if nargin < 4
        setfcn = [];
    end
end

% Add the dynamic property.
hp = schema.prop(h, name, datatype);
set(hp, 'AccessFlags.Serialize', 'Off', ...
    'SetFunction', setfcn, ...
    'GetFunction', getfcn);

if nargout
    varargout = {hp};
end

% [EOF]
