MATLAB: How to correcty set this error?

errorerrordlgpathuigetfile

Hi everybody!! I have to set an error when I read a file.
My error box has to appear when users press "Load" before choosing the file.
I tried lots of combinations, but it doesn't work… It only shows me a textread error like:
??? Error using ==> textread at 167
File not found.
Error in ==> E1_Amm_IT>PB_Carica_Callback at 202
[anno azienda istituto disciplina_dimissione prog_reparto ...
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> E1_Amm_IT at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)E1_Amm_IT('PB_Carica_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
I post you my code:
function PB_Browse_Callback(hObject, eventdata, handles)
global file
[file path] = uigetfile('*.txt');
global filepath
filepath = strcat(path, file);
set(handles.ET_Path, 'String', filepath);
filename=get(handles.ET_Path, 'String');
global filepath;
if strcmp(filepath, '')==1
errordlg('Choose a file!', 'ERROR!');
elseif strcmp(filepath, '')==0
% My .m file runs
How can I fix it??

Best Answer

Why don't you simply set PB_Carica 'enable' to 'off' until the browsing has been done?