function setlist(h, val)
%SETLIST Set the string and value of a UILIST control
%
%        SETLIST(H, VALUE)
%
%    This function is used by UILIST.
%
%       H      is the handle of UILIST control.
%       VALUE  is the new value of the list or the new string.
%
%

% 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');

if isempty(bdf)
	return;
end

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

if isstr(val)
	if get(h, 'min')==0  %Case insensitive
		s=findstr(upper(deblank([sep val])), upper(bdf));
	else                 %Case sensitive
		s=findstr(deblank([sep val]), bdf);
	end
	if isempty(s) | length(s)>1
		val=get(h, 'value');
	else
		val=find(p==s);
	end
else
	if val>length(p)
		val=length(p);
	end
	if val<1
		val=1;
	end
end

p=[p length(bdf)];

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

set(h, 'string', str, 'value', val);


return

