annotate aim-mat/tools/@parameter/getas.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=getas(param,text,selectedunit,panel)
tomwalters@0 9 % returns the current value of the parameter if its an float or an int
tomwalters@0 10
tomwalters@0 11 cont=param.entries;
tomwalters@0 12 nrent=length(cont);
tomwalters@0 13
tomwalters@0 14 if nargin<4 % search in all subsections
tomwalters@0 15 panel='all';
tomwalters@0 16 end
tomwalters@0 17
tomwalters@0 18 nr=getentrynumberbytext(param,text,panel);
tomwalters@0 19
tomwalters@0 20 if nr>0
tomwalters@0 21 type=cont{nr}.type;
tomwalters@0 22
tomwalters@0 23 if nargin==2
tomwalters@0 24 selectedunit=cont{nr}.orgunit;
tomwalters@0 25 end
tomwalters@0 26
tomwalters@0 27 handleb=gethandle(param,text,panel,1);
tomwalters@0 28 if ~isequal(handleb,0) && ishandle(handleb) % yes, there is a screen representation
tomwalters@0 29 strvalue=get(handleb,'string'); % value is a string, lets see what we make of it
tomwalters@0 30 if ~strcmp(strvalue,'auto')
tomwalters@0 31 orgvalue=str2num(strvalue); % its a float, it must have a value
tomwalters@0 32
tomwalters@0 33 unitty=cont{nr}.unittype;
tomwalters@0 34 if isa(unitty,'unit_none')
tomwalters@0 35 rawvalue=orgvalue;
tomwalters@0 36 selectedunit='';
tomwalters@0 37 else
tomwalters@0 38 cunit=getcurrentunit(param,text);
tomwalters@0 39 rawvalue=fromunits(unitty,orgvalue,cunit); % translate to rawdata
tomwalters@0 40 testvalue=tounits(unitty,rawvalue,cont{nr}.orgunit); %the unit in which the min and max values are defined
tomwalters@0 41 val=fromunits(unitty,orgvalue,selectedunit); % translate to asked unit
tomwalters@0 42 end
tomwalters@0 43 val=tounits(unitty,rawvalue,selectedunit);
tomwalters@0 44 return
tomwalters@0 45 else
tomwalters@0 46 val='auto';
tomwalters@0 47 return
tomwalters@0 48 end
tomwalters@0 49 else % no representation on screen
tomwalters@0 50 unittype=param.entries{nr}.unittype;
tomwalters@0 51 rawval=cont{nr}.rawvalue;
tomwalters@0 52 stringval=cont{nr}.stringvalue;
tomwalters@0 53 if isequal(rawval,'auto')
tomwalters@0 54 val=rawval;
tomwalters@0 55 return
tomwalters@0 56 end
tomwalters@0 57 if isa(unittype,'unit_none')
tomwalters@0 58 val=str2num(stringval);
tomwalters@0 59 else
tomwalters@0 60 val=tounits(unittype,rawval,selectedunit);
tomwalters@0 61 end
tomwalters@0 62 end
tomwalters@0 63 else
tomwalters@0 64 error('getas:: error, the entry does not exist');
tomwalters@0 65 end