annotate aim-mat/tools/@parameter/get.m @ 4:537f939baef0 tip

various bug fixes and changed copyright message
author Stefan Bleeck <bleeck@gmail.com>
date Tue, 16 Aug 2011 14:37:17 +0100
parents 20ada0af3d7d
children
rev   line source
tomwalters@0 1 % method of class @parameter
tomwalters@0 2 %
bleeck@3 3 % (c) 2011, University of Southampton
bleeck@3 4 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 5 % download of current version is on the soundsoftware site:
bleeck@3 6 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 7 % documentation and everything is on http://www.acousticscale.org
tomwalters@0 8 function val=get(param,text,panel)
tomwalters@0 9 % returns the current value of the parameter
tomwalters@0 10
tomwalters@0 11 cont=param.entries;
tomwalters@0 12 nrent=length(cont);
tomwalters@0 13
tomwalters@0 14 if nargin <2 % in case we want the whole stucture
tomwalters@0 15 val=cont;
tomwalters@0 16 return
tomwalters@0 17 end
tomwalters@0 18
tomwalters@0 19 if nargin<3 % search in all subsections
tomwalters@0 20 panel='all';
tomwalters@0 21 end
tomwalters@0 22
tomwalters@0 23
tomwalters@0 24 nr=getentrynumberbytext(param,text,panel);
tomwalters@0 25
tomwalters@0 26 if nr>0
tomwalters@0 27 type=cont{nr}.type;
tomwalters@0 28
tomwalters@0 29 handleb=gethandle(param,text,panel,1);
tomwalters@0 30 if ~isequal(handleb,0) && ishandle(handleb) % yes, there is a screen representation
tomwalters@0 31 if strcmp(get(handleb,'type'),'uipanel') && strcmp(type,'panel')
tomwalters@0 32 val=getradiobutton(param,text);
tomwalters@0 33 else
tomwalters@0 34 strval=get(handleb,'string');
tomwalters@0 35 if strcmp(type,'pop-up menu')
tomwalters@0 36 nrsel=get(handleb,'value');
tomwalters@0 37 val=strval{nrsel};
tomwalters@0 38 elseif strcmp(type,'radiobutton')
tomwalters@0 39 val=get(handleb,'value');
tomwalters@0 40 elseif strcmp(type,'bool')
tomwalters@0 41 val=get(handleb,'value');
tomwalters@0 42 elseif strcmp(type,'int')
tomwalters@0 43 if strcmp(strval,'auto');
tomwalters@0 44 val=strval;
tomwalters@0 45 else
tomwalters@0 46 val=str2num(strval);
tomwalters@0 47 end
tomwalters@0 48 elseif strcmp(type,'float')
tomwalters@0 49 unit=cont{nr}.orgunit;
tomwalters@0 50 val=getas(param,text,unit,panel); %call new with unit
tomwalters@0 51 else
tomwalters@0 52 val=strval;
tomwalters@0 53 end
tomwalters@0 54 return
tomwalters@0 55 end
tomwalters@0 56 else % no screen representation
tomwalters@0 57 if strcmp(type,'float')
tomwalters@0 58 unit=cont{nr}.orgunit;
tomwalters@0 59 val=getas(param,text,unit,panel); %call new with unit
tomwalters@0 60 return
tomwalters@0 61 elseif strcmp(type,'int')
tomwalters@0 62 valf=cont{nr}.value;
tomwalters@0 63 if ischar(valf)
tomwalters@0 64 if strcmp(valf,'auto');
tomwalters@0 65 val=valf;
tomwalters@0 66 else
tomwalters@0 67 val=str2num(valf);
tomwalters@0 68 end
tomwalters@0 69 else
tomwalters@0 70 val=valf;
tomwalters@0 71 end
tomwalters@0 72 elseif strcmp(type,'panel')
tomwalters@0 73 val=getradiobutton(param,text);
tomwalters@0 74 else
tomwalters@0 75 val=cont{nr}.value;
tomwalters@0 76 return
tomwalters@0 77 end
tomwalters@0 78 end
tomwalters@0 79 else
tomwalters@0 80 error('error, the entry does not exist');
tomwalters@0 81 % val=0; % we must return a logical value otherwise it can generate difficult errors
tomwalters@0 82 end