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 param=set(param,text,newvalue,inbox) tomwalters@0: %% sets the parameter value in the parameter "text" in the panel "inbox" to tomwalters@0: %% the value "value". tomwalters@0: % if its a float then the unit is assumed to be the one with wich the tomwalters@0: % parameter was first defined tomwalters@0: tomwalters@0: if nargin<4 tomwalters@0: inbox='all'; tomwalters@0: end tomwalters@0: tomwalters@0: cont=param.entries; tomwalters@0: nr=getentrynumberbytext(param,text,inbox); tomwalters@0: if nr>0 tomwalters@0: type=cont{nr}.type; tomwalters@0: if strcmp(type,'float') || strcmp(type,'slider') tomwalters@0: unit=cont{nr}.orgunit; tomwalters@0: param=setas(param,text,newvalue,unit,inbox); %call new with unit tomwalters@0: return tomwalters@0: else tomwalters@0: param.entries{nr}.value=newvalue; % set the value in the class structure tomwalters@0: end tomwalters@0: if isfield(cont{nr},'handle') && ishandle(cont{nr}.handle{1}) % and set in the gui as well tomwalters@0: hand=cont{nr}.handle{1}; tomwalters@0: if strcmp(type,'float') || strcmp(type,'string') || strcmp(type,'filename') || strcmp(type,'directoryname') tomwalters@0: set(hand,'String',newvalue); tomwalters@0: elseif strcmp(type,'int') % ints are capped tomwalters@0: if isnumeric(newvalue) tomwalters@0: intnewvalue=round(newvalue); tomwalters@0: if length(intnewvalue)==1 tomwalters@0: set(hand,'String',intnewvalue); tomwalters@0: else tomwalters@0: set(hand,'String',num2str(intnewvalue)); tomwalters@0: end tomwalters@0: param.entries{nr}.value=intnewvalue; % set the value in the class structure tomwalters@0: else tomwalters@0: set(hand,'String',newvalue); tomwalters@0: end tomwalters@0: else tomwalters@0: if strcmp(type,'pop-up menu') tomwalters@0: cont=param.entries{nr}.possible_values; tomwalters@0: for i=1:length(cont) tomwalters@0: if strcmp(cont{i},newvalue) tomwalters@0: set(hand,'value',i); tomwalters@0: end tomwalters@0: end tomwalters@0: else tomwalters@0: set(hand,'value',newvalue); % could be bool tomwalters@0: end tomwalters@0: end tomwalters@0: end tomwalters@0: return tomwalters@0: else tomwalters@0: error('setvalue::error, the entry does not exist'); tomwalters@0: end