
List Box Directory Reader
10-11
• First input argument is not a directory, but is a character string and there is
more than one argument — execute the subfunction identified by the
argument (execute callback).
The following code listing show the setup section of the GUI M-file, which does
one the following:
• Sets the list box directory to the current directory, if no directory is specified.
• Changes the current directory, if a directory is specified.
function lbox2_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to untitled (see VARARGIN)
% Choose default command line output for lbox2
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
if nargin == 3,
initial_dir = pwd;
elseif nargin > 4
if strcmpi(varargin{1},'dir')
if exist(varargin{2},'dir')
initial_dir = varargin{2};
else
errordlg({'Input argument must be a valid',...
'directory'},'Input Argument Error!')
return
end
else
errordlg('Unrecognized input argument',...
'Input Argument Error!');
return;
end
end
Kommentare zu diesen Handbüchern