User`s guide
An Address Book Reader (GUIDE)
% Load the default address boo k
Check_And_Load([],handles);
% If the fi rst element in vara rgi n is 'book' and
& the second element is a MATLAB file, then load that file
elseif (leng th(v arargin) == 2 & & ...
strcmpi(varargin{1},'book') && ...
(2 == exist(varargin{2},'file')))
Check_And_Load(varargin{2},handles);
else
errordlg('File Not Found','File Lo ad Error')
set(handles.Contact_Name,'String','')
set(handles.Contact_Phone,'String','')
end
Load an Address Book Into the Reader
There are two ways in which the GUI accesses an address book (text data
stored in a MAT-fil e):
• Wh en starting the GUI, you can specify a M AT-file as an argument. For
example,
address_book ad drbo ok.mat
If you do not specify an argument, the GUI loads the default addres s book
(
addrbook.mat, one of the three example files).
• From the File menu, select Open to display a file dialog box and browse
for other MAT-files.
Validate the MAT-file
To be a valid address book, the MAT-file m ust contain a structure called
Addresses that has tw o fields called Name and Pho ne.TheCheck_And_ Load
subfunction validates and loads the data with the following steps:
• Loads (
load) the specified file or the default if none is specified.
• Determines if the M AT-file is a valid address book.
• Displays the data if it is valid. If it is not valid, displays an error dialog
box (
errordlg).
10-85