tomwalters@0: % method of class @parameter tomwalters@0: % bleeck@3: % (c) 2011, University of Southampton bleeck@3: % Maintained by Stefan Bleeck (bleeck@gmail.com) bleeck@3: % download of current version is on the soundsoftware site: bleeck@3: % http://code.soundsoftware.ac.uk/projects/aimmat bleeck@3: % documentation and everything is on http://www.acousticscale.org tomwalters@0: function val=getas(param,text,selectedunit,panel) tomwalters@0: % returns the current value of the parameter if its an float or an int tomwalters@0: tomwalters@0: cont=param.entries; tomwalters@0: nrent=length(cont); tomwalters@0: tomwalters@0: if nargin<4 % search in all subsections tomwalters@0: panel='all'; tomwalters@0: end tomwalters@0: tomwalters@0: nr=getentrynumberbytext(param,text,panel); tomwalters@0: tomwalters@0: if nr>0 tomwalters@0: type=cont{nr}.type; tomwalters@0: tomwalters@0: if nargin==2 tomwalters@0: selectedunit=cont{nr}.orgunit; tomwalters@0: end tomwalters@0: tomwalters@0: handleb=gethandle(param,text,panel,1); tomwalters@0: if ~isequal(handleb,0) && ishandle(handleb) % yes, there is a screen representation tomwalters@0: strvalue=get(handleb,'string'); % value is a string, lets see what we make of it tomwalters@0: if ~strcmp(strvalue,'auto') tomwalters@0: orgvalue=str2num(strvalue); % its a float, it must have a value tomwalters@0: tomwalters@0: unitty=cont{nr}.unittype; tomwalters@0: if isa(unitty,'unit_none') tomwalters@0: rawvalue=orgvalue; tomwalters@0: selectedunit=''; tomwalters@0: else tomwalters@0: cunit=getcurrentunit(param,text); tomwalters@0: rawvalue=fromunits(unitty,orgvalue,cunit); % translate to rawdata tomwalters@0: testvalue=tounits(unitty,rawvalue,cont{nr}.orgunit); %the unit in which the min and max values are defined tomwalters@0: val=fromunits(unitty,orgvalue,selectedunit); % translate to asked unit tomwalters@0: end tomwalters@0: val=tounits(unitty,rawvalue,selectedunit); tomwalters@0: return tomwalters@0: else tomwalters@0: val='auto'; tomwalters@0: return tomwalters@0: end tomwalters@0: else % no representation on screen tomwalters@0: unittype=param.entries{nr}.unittype; tomwalters@0: rawval=cont{nr}.rawvalue; tomwalters@0: stringval=cont{nr}.stringvalue; tomwalters@0: if isequal(rawval,'auto') tomwalters@0: val=rawval; tomwalters@0: return tomwalters@0: end tomwalters@0: if isa(unittype,'unit_none') tomwalters@0: val=str2num(stringval); tomwalters@0: else tomwalters@0: val=tounits(unittype,rawval,selectedunit); tomwalters@0: end tomwalters@0: end tomwalters@0: else tomwalters@0: error('getas:: error, the entry does not exist'); tomwalters@0: end