function setcpush(h, val)
%SETCPUSH Set the string and value of a UICPUSH control.
%
%        SETCPUSH(H, VALUE)
%
%    This function is used by UICPUSH.
%
%       H      is the handle of UICPUSH control.
%       VALUE  is the new value of the list.
%
%

% This function can be modified with the only restriction that the
% next two lines have to be reteined.
%             Copyright (c) 1996 by Claudio Rivetti 
%                  claudio@alice.uoregon.edu
%
% Last version: October 6, 1996.
% ENJOY IT!
%

bdf=get(h, 'ButtonDownFcn');
mode=get(h, 'max');

if isempty(bdf) | mode==0
	return;
end

bdf=bdf(2:length(bdf));
sep=bdf(1);
p=findstr(bdf, sep);


if abs(mode)==1
	if val<length(p)
		val=val+1;
	else
		val=1;
	end
elseif abs(mode)==2
	if val>1 & val<length(p)
		val=val+(1*sign(mode));
	elseif val==length(p)
		val=val-1;
		mode=abs(mode)*(-1);
	elseif val==1 
		val=val+1;
		mode=abs(mode);
	end	
elseif abs(mode)>2
	if val<length(p)
		val=val+1;
	else
		val=length(p);
	end
end

p=[p length(bdf)];

a=p(val);
b=p(val+1);
str=strrep(bdf(a:b), sep, '');

set(h, 'string', str, 'min', val, 'max', mode, 'value', val);

return

