User`s guide
Initialize a GUIDE GUI
GUI template, available from the GUIDE Quick Start dialog box. The added
code opens the modal dialog w ith a message, specified from the command line
or by another G UI that calls this one. For example,
mygui('String','Do you want to exit?')
displays the text 'Do y ou want to exit?' ontheGUI.Todothis,youneed
to customize the opening function because
'String' is not a valid figure
property, it is a static text property. The Modal Question Dialog template file
contains the following code, which
• Uses the
nargin function to determine the number of user-specified
arguments (which do not include
hObject, eventdata,andhandles)
• Parses
varargin to obtain property name/value pairs, converting each
name string to lower case
• Handles the case where the argument
'title' is used an alias for the
figure
Name property
• Handles the case
'string' , assigning the following value as a String
property to the appropriate static text object
function modalgui_Opening Fcn(hObject, eventdata, handles, varargin)
.
.
.
% Insert custom Title and Text if specified by the user
% Hint: when choosing keyw ords, be sure the y are not easily confused
% with existing figure pro perties. See the output of set(fi gure) for
% a list of figure properties.
if(nargin > 3)
for index = 1:2:(nargin-3),
if nargin-3==index, break, end
switch lower(varargin{inde x})
case 'title'
set(hObject, 'Name', varargin{index+1});
case 'string'
set(handles.text1, 'Str ing', varargin{index+1});
end
end
end
8-27