User`s guide

An Address Book Reader (GUIDE)
end
% If the file is valid, display it
if pass
% Add Addresses to the handles structure
handles.Addresses = data.Addresses;
guidata(handles.Address_Book,handles)
% Display the first entry
set(handles.Contact_Name,'String',data .Addresses(1).Name)
set(handles.Contact_Phone,'String',dat a.Addresses(1).Phone)
% Set the index pointer to 1 and save handle s
handles.Index = 1;
guidata(handles.Address_Book,handles)
else
errordlg('Not a valid Address Book','Address Book Error')
end
The Open Menu Callback
The address book GUI contains a File menu that has an Open submenu for
loading address book MAT-files. When selected, Open displays a dialog box
(
uigetfile)thatenablestheusertobrowseforfiles.Thedialogboxdisplays
only MAT-file s, but users ca n c h an ge th e filte r to disp la y all files.
The dialogbox returns both the file name and the path to the file, which is
then passed to
fullfile to ensure the p ath is properly constructed for any
platform.
Check_And_Load validates and load the new address b ook.
Open_Callback Code Listing
function Open_C allb ack(hObject, eventd ata, handles)
[filename, p athn ame] = uigetfile( . ..
{'*.mat', 'All MAT-Files (*.mat)'; ...
'*.*','All Fi les (*.*)'}, ...
'Select Address Book');
% If "Cancel" is selected then return
if isequal([ file name,pathname],[0,0])
return
% Otherwise construct the fullfilename and Che ck and load
% the file
else
10-87