% method of class @parameter
%
% (c) 2003-2008, University of Cambridge
% Maintained by Tom Walters (tcw24@cam.ac.uk), written by Stefan Bleeck (stefan@bleeck.de)
% http://www.pdn.cam.ac.uk/cnbh/aim2006/tools/parameter
% $Date: 2008-06-10 18:00:16 +0100 (Tue, 10 Jun 2008) $
function str=getradiobutton(param,panel)


cont=param.entries;
nrent=length(cont);


for i=1:nrent
    type=cont{i}.type;
    if strcmp(type,'radiobutton')
        if strcmp(cont{i}.panel,panel)
            handleb=gethandle(param,cont{i}.text,cont{i}.panel,1);
            if ~isequal(handleb,0) && ishandle(handleb) % yes, there is a screen representation
                val=get(handleb,'value');
                if val==1
                    text=cont{i}.text;
                    panel=cont{i}.panel;
                    if strcmp(text,'other...')
                        handle2=gethandle(param,text,panel,2);
                        str=get(handle2,'string');
                    else
                        str=text;
                    end
                    return
                end
            else
                if cont{i}.value==1
                    str=cont{i}.text;
                    if strcmp(str,'other...')
                        str=cont{i}.userdata;
                    end
                    return
                end
            end
        end
    end
end



% if still here then non identical fit
% search for fragment

for i=1:nrent
    type=cont{i}.type;
    if strcmp(type,'radiobutton')
        if ~isempty(strfind(cont{i}.panel,panel))
            handleb=gethandle(param,cont{i}.text,cont{i}.panel,1);
            if ishandle(handleb) % yes, there is a screen representation
                val=get(handleb,'value');
                if val==1
                    text=cont{i}.text;
                    panel=cont{i}.panel;
                    if strcmp(text,'other...')
                        handle2=gethandle(param,text,panel,2);
                        str=get(handle2,'string');
                    else
                        str=text;
                    end
                    return
                end
            else
                if cont{i}.value==1
                    str=cont{i}.text;
                    if strcmp(str,'other...')
                        str=cont{i}.userdata;
                    end
                    return
                end
            end
        end
    end
end

str='error, the entry does not exist';