- retrieves the popup menu name in the GUI copyright 2009-2012 Blair Armstrong, Christine Watson, David Plaut This file is part of SOS SOS is free software: you can redistribute it and/or modify it for academic and non-commercial purposes under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. For commercial or for-profit uses, please contact the authors (sos@cnbc.cmu.edu). SOS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
0001 % - retrieves the popup menu name in the GUI 0002 % 0003 % copyright 2009-2012 Blair Armstrong, Christine Watson, David Plaut 0004 % 0005 % This file is part of SOS 0006 % 0007 % SOS is free software: you can redistribute it and/or modify 0008 % it for academic and non-commercial purposes 0009 % under the terms of the GNU General Public License as published by 0010 % the Free Software Foundation, either version 3 of the License, or 0011 % (at your option) any later version. For commercial or for-profit 0012 % uses, please contact the authors (sos@cnbc.cmu.edu). 0013 % 0014 % SOS is distributed in the hope that it will be useful, 0015 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 % GNU General Public License for more details. 0018 0019 % You should have received a copy of the GNU General Public License 0020 % along with SOS (see COPYING.txt). 0021 % If not, see <http://www.gnu.org/licenses/>. 0022 0023 0024 0025 function valName = getPopupMenuName(handle,msg,msgTitle) 0026 % retrieves the string representation of the selection in a popup menu 0027 % referenced by handle. Displays an informative error message if no 0028 % selection is made or the popup list is empty. 0029 0030 valIndex = get(handle,'Value'); 0031 valStr = get(handle,'String'); 0032 0033 0034 if isempty(valStr) == 0 0035 if iscell(valStr) 0036 valName = valStr{valIndex}; 0037 elseif ischar(valStr) 0038 %if it's a string, it indicates that there is only one entry in 0039 %the popup menu, so return that entire entry 0040 valName = valStr; 0041 else 0042 error('Unrecognized popup array entry'); 0043 end 0044 0045 else 0046 valName = ''; 0047 end 0048 0049 0050 if isempty(valName) == 0 0051 % success 0052 else 0053 msgbox(msg,msgTitle); 0054 end 0055 0056 end 0057