Specifications

5 GUI Applications
5-14
index_selected = get(handles.listbox1,'Value');
file_list = get(handles.listbox1,'String');
filename = file_list{index_selected}; % Item selected in list box
if handles.is_dir(handles.sorted_index(index_selected)) % If directory
cd (filename)
load_listbox(pwd,handles) % Load list box with new directory
else
[path,name,ext,ver] = fileparts(filename);
switch ext
case '.fig'
guide (filename) % Open FIG-file with guide command
otherwise
try
open(filename) % Use open for other file types
catch
errordlg(lasterr,'File Type Error','modal')
end
end
end
end
Opening Unknown File Types
You can extend the file types that the open command recognizes to include any
file having a three-character extension. You do this by creating an M-file with
the name
openxyz, where xyz is the extension. Note that the list box callback
does not take this approach for FIG-files since
openfig.m is required by the
GUI M-file. See
open for more information.