Creating Graphical User Interfaces | ![]() ![]() |
Launching the GUI
The GUI is nonblocking and nonmodal since it is designed to be displayed while you perform other MATLAB tasks.
Application Options Settings
This GUI uses the following application option settings:
Generate callback function prototypes
Application allows only one instance to run
Launching the GUI
You can call the application M-file with no arguments, in which case, the GUI uses the default address book MAT-file, or you can specify a MAT-file as an argument. Specifying a MAT-file as an input argument requires modification to the default GUI initialization section of the application M-file. The following code shows these changes in bold.
function varargout = address_book(varargin)if nargin <= 1
% LAUNCH GUI
fig = openfig(mfilename,'reuse'); set(fig,'Color',get(0,'defaultUicontrolBackgroundColor')); handles = guihandles(fig); guidata(fig, handles);if nargin == 0
% Load the default address book
Check_And_Load([],handles)
elseif exist(varargin{1},'file')
Check_And_Load(varargin{1},handles)
else
% If the file does not exist, return an error dialog
% and set the text to empty strings
errordlg('File Not Found','File Load Error')
set(handles.Contact_Name,'String','')
set(handles.Contact_Phone,'String','')
end
if nargout > 0 varargout{1} = fig; end elseif ischar(varargin{1})% INVOKE NAMED SUBFUNCTION OR CALLBACK
try [varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard catch disp(lasterr); end end
![]() | An Address Book Reader | Loading an Address Book Into the Reader | ![]() |