%function ii = findin(c,field,str,reverse)
% c is a cell array of structs
% reverse is optional
function ii = findin(c,field,str,reverse)

if nargin == 3, reverse = 0; end
if ~reverse, iterate = 1:length(c);
else iterate = length(c):-1:1; end
str = lower(str);
field = lower(field);
for ii=iterate,
	if isfield(c{ii},field),
		if strcmp(getfield(c{ii},field),str), return, end
	end
end
ii = 0;