User`s guide
10 Examples of GUIDE GUIs
File = fullfile(pathname,filename) ;
% if the M AT-f ile is not valid, do not save the name
if Check_And_Lo ad(F ile,handles)
handles.LastFIle = File;
guidata(hObject, handles)
end
end
Ffor information on creating the menu, see “Create Menus in a GUIDE GUI”
on page 6-101.
The Contact Name Callback
The Contact Name text box displays the name of the address book entry. If
you type in a new nam e and press enter, the callback p erforms these steps:
• If the name exists in the current address book, the corresponding phone
number is d isplayed.
• If the name does not exist, a question dialog box (
questdlg)asksyouifyou
want to create a new entry or cancel and return to the name previously
displayed.
• If you create a new entry, you must save the MAT-file using the
File > Save menu.
Store and Retrieve Data
This callback uses the handles structure to access the contents of the address
book and to maintain an index pointer (
handles.Index)thatenablesthe
callback to determine what name was displayed before it was changed by the
user. The index pointer indicates what name is currently displayed. The
address book and index pointer fields are added by the
Check_And_Load
function when the GUI is run.
If the user adds a new entry, the callback adds the new name to the address
book and updates the index pointer to reflect the new value displayed. The
updated address book and index pointer are again saved (
guidata)inthe
handles structure.
10-88