User`s guide
10 Examples of GUIDE GUIs
file_list = get(handles.listbox1,' String');
% Item selected in list box
filename = file_list{index_selecte d};
% If folder
if handles.is_dir(handles.sorted_index(in dex_selected))
cd (filename)
% Load list box with new folder.
load_listbox(pwd,handles)
else
[path,name,ext] = fileparts(filename);
switch ext
case '.fig'
% Open FIG-file with guide command.
guide (filen ame)
otherwise
try
% Use open for other file types.
open(filename)
catch ex
errordlg(...
ex.getReport('basic'),'File Type Error','modal')
end
end
end
end
Open Unknown File Types. Y ou can extend the file types that the open
command recognizes to include any file having a three-character extension.
Do this by creating a MATLAB code file with the name
openxyz.m. xyz is the
fileextensionforthetypeoffilestobehandled. Donot,however,takethis
approach for opening FIG-files, because
openfig.m is a MATLAB function
which is neede d to ope n GUIs. For more information, see
open and openfig.
10-60