Can anyone see whats wrong here, Im using a popup menu to select which file types to list in a list box
Warning: Single-selection 'listbox' control requires that 'Value' be an integer within String rangeControl will not be rendered until all of its parameter values are valid
It works fine when I select
*.* as the filter, which is my case 1 below
On the popupmenu callback, I use
%Get user selected file type
popup_sel_index = get(handles.popupmenu1, 'Value');switch popup_sel_index case 1 filenameFilter = '*.*'; ImageFiles = dir(fullfile(folder,filenameFilter)); case 2 filenameFilter = '*.tif*'; ImageFiles = dir(fullfile(folder,filenameFilter)) ; set(handles.pbDraw,'Enable','on'); case 3 filenameFilter = '*.jpg*'; ImageFiles = dir(fullfile(folder,filenameFilter)); set(handles.pbDraw,'Enable','on'); case 4 filenameFilter = '*.idat*'; ImageFiles = dir(fullfile(folder,filenameFilter)); set(handles.pbDraw,'Enable','off'); case 5 filenameFilter = '*.gtc'; ImageFiles = dir(fullfile(folder,filenameFilter)); set(handles.pbDraw,'Enable','off'); case 6 filenameFilter = '*.log*'; ImageFiles = dir(fullfile(folder,filenameFilter)); set(handles.pbDraw,'Enable','off'); case 7 filenameFilter = '*.xls*'; ImageFiles = dir(fullfile(folder,filenameFilter)); set(handles.pbDraw,'Enable','off'); set(handles.editPrefix,'String','C01-'); case 8 filenameFilter = '*red.tif*'; ImageFiles = dir(fullfile(folder,filenameFilter)); set(handles.pbDraw,'Enable','on'); case 9 filenameFilter = '*grn.tif*'; ImageFiles = dir(fullfile(folder,filenameFilter)); set(handles.pbDraw,'Enable','on'); endguidata(hObject,handles);drawnow; %populate listbox with files
ListOfImageNames = {}; for Index = 1:length(ImageFiles) baseFileName = ImageFiles(Index).name; [folder1, name, extension] = fileparts(baseFileName); extension = upper(extension); ListOfImageNames = [ListOfImageNames baseFileName]; end ListOfImageNames set(handles.listbox1, 'string', ListOfImageNames); drawnow; %count files in listbox
str = get( handles.listbox1, 'String' ); % Get number of
lc = numel( str ); %disp('gtc selected true');
Best Answer