Specifications

5 Application Examples
5-20
The following code listing show the entire initialization section of the
application M-file. The statements in bold are the additions made to the
generated code.
function varargout = lbox2(varargin)
if nargin <= 1 % LAUNCH GUI
if nargin == 0
initial_dir = pwd;
elseif nargin == 1 & exist(varargin{1},'dir')
initial_dir = varargin{1};
else
errordlg('Input argument must be a valid directory',...
'Input Argument Error!')
return
end
fig = openfig(mfilename,'reuse');
% Use system color scheme for figure:
set(fig,'Color',get(0,'defaultUicontrolBackgroundColor'));
% Generate a structure of handles to pass to callbacks, and store it.
handles = guihandles(fig);
guidata(fig, handles);
% Populate the listbox
load_listbox(varargin{1},handles)
if nargout > 0
varargout{1} = fig;
end
elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK
try
if (nargout)
[varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard
else
feval(varargin{:}); % FEVAL switchyard
end
catch
disp(lasterr);
end
end