annotate aim-mat/tools/@parameter/getentrynumberbytext.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 nr=getentrynumberbytext(param,text,inbox)
tomwalters@0 9
tomwalters@0 10 nr=-1;
tomwalters@0 11
tomwalters@0 12
tomwalters@0 13
tomwalters@0 14 if nargin<3 % search in all subsections
tomwalters@0 15 inbox='all';
tomwalters@0 16 end
tomwalters@0 17
tomwalters@0 18 cont=param.entries;
tomwalters@0 19 nrent=length(cont);
tomwalters@0 20
tomwalters@0 21
tomwalters@0 22 % text can be a string or a number
tomwalters@0 23 if isstr(text) % if its a sting then look for the member number
tomwalters@0 24 % first search for the exact fit
tomwalters@0 25 for i=1:nrent
tomwalters@0 26 if strcmp(cont{i}.text,text) && (strcmp(cont{i}.panel,inbox) || strcmp(inbox,'all'))
tomwalters@0 27 nr=i;
tomwalters@0 28 return
tomwalters@0 29 end
tomwalters@0 30 end
tomwalters@0 31
tomwalters@0 32
tomwalters@0 33 % then search for the abbreviation
tomwalters@0 34 for i=1:nrent
tomwalters@0 35 if ~isempty(strfind(cont{i}.text,text)) && (strcmp(cont{i}.panel,inbox) || strcmp(inbox,'all'))
tomwalters@0 36 nr=i;
tomwalters@0 37 return
tomwalters@0 38 end
tomwalters@0 39 end
tomwalters@0 40 else
tomwalters@0 41 nr=text; % in this case we wanted to access it by the number
tomwalters@0 42 end
tomwalters@0 43