Creating Graphical User Interfaces    

Loading an Address Book Into the Reader

There are two ways in which an address book (i.e., a MAT-file) is loaded into the GUI:

Validating the MAT-file

To be a valid address book, the MAT-file must contain a structure called Addresses that has two fields called Name and Phone. The Check_And_Load subfunction validates and loads the data with the following steps:

Check_And_Load Code Listing

This is the Check_And_Load function.

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 (uigetfile) that enables the user to browser for files. The dialog displays only MAT-files, but users can change the filter to display all files.

The dialog returns both the filename and the path to the file, which is then passed to fullfile to ensure the path is properly constructed for any platform. Check_And_Load validates and load the new address book.

Open_Callback Code Listing

See the Creating Menus - The Menu Editor section for information on creating the menu.


  Running the GUI The Contact Name Callback