% 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 hand=gethandle(param,text,panel,handnr)
% set handle of one line. A line can have more then one handle, therefore
% nr can be bigger then one

if nargin<4
    handnr=1;
end

if nargin<3
    panel='all';
end

nr=getentrynumberbytext(param,text,panel);

if nr>0
    if ~isfield(param.entries{nr},'handle')
        hand=0;
%         disp('error: handle does not exist');
        return
    end
    if length(param.entries{nr}.handle)>=handnr
        hand=param.entries{nr}.handle{handnr};
        if length(hand)>1
            hand=hand(handnr);
        end
    else
        hand=[];
    end
else
    hand=0;
    disp('error: handle does not exist');
end
