How to correcty set this error??

1 Ansicht (letzte 30 Tage)
Jethro
Jethro am 19 Jan. 2012
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??
  2 Kommentare
Andrew Newell
Andrew Newell am 19 Jan. 2012
Can you post the code with the textread command in it?
Walter Roberson
Walter Roberson am 19 Jan. 2012
We need to see the code for PB_Carica_Callback
Also, please read
http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.3F

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 19 Jan. 2012
Why don't you simply set PB_Carica 'enable' to 'off' until the browsing has been done?
  1 Kommentar
Jethro
Jethro am 19 Jan. 2012
Yes I think it's the better and simple solution!!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Jethro
Jethro am 19 Jan. 2012
I posted my textread code and after it, my PB_Carica_Callback (it' very very long, it operates on my files cleaning wrong cells!!!)
TEXTREAD
% CONTROL ABOUT NUMBER OF COLUMNS
fmt = repmat('%s', 1, 31);
length(fmt);
if length(fmt)~=62
errordlg('ERROR!!',...
'ERROR!!');
else
[anno azienda istituto disciplina_dimissione prog_reparto ...
regime_ricovero provenienza drg degenza dh importo_reg data_dim ...
residenza eta sesso d_principale d_com1 d_com2 d_com3 d_com4...
int_prin int_sec1 int_sec2 int_sec3 int_sec4 mod_accesso...
mod_dimissione tipo_ricovero data_ingresso tipo_prescrittore ...
cod_nos]=textread(filename,'%s %s %s %s %s %s %s %s %d %d %d %s %s %d %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s','delimiter','\t');
-------------------------------------------------------------
PB_CARICA_CALLBACK, DON'T MIND WAITBAR LINES
function PB_Carica_Callback(hObject, eventdata, handles)
filename=get(handles.ET_Percorso, 'String');
global filepath;
if strcmp(filepath, '')==1
errordlg('ERROR!', 'ERROR!!');
elseif strcmp(filepath, '')==0
global istituto;
global prog_reparto;
global degenza;
global istituto_num;
global rep_num;
[...]
global int_sec1;
global int_sec2;
global int_sec3;
global int_sec4;
%wb=waitbar(0, 'Loading... 0%');
[anno azienda istituto disciplina_dimissione prog_reparto ...
regime_ricovero provenienza drg degenza dh importo_reg data_dim ...
residenza eta sesso d_principale d_com1 d_com2 d_com3 d_com4...
int_prin int_sec1 int_sec2 int_sec3 int_sec4 mod_accesso...
mod_dimissione tipo_ricovero data_ingresso tipo_prescrittore ...
cod_nos]=textread(filename,'%s %s %s %s %s %s %s %s %d %d %d %s %s %d %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s','delimiter','\t');
%%%%INIZIO DEPURAZIONE %%%%
%%conversione dell'importo regionale da lire ad euro
importo_euro=(importo_reg/1936.27);
%%Eliminazione dei record vuoti
is_anno=find(strcmp(anno,'')==1);
is_azienda=find(strcmp(azienda,'')==1);
is_istituto=find(strcmp(istituto,'')==1);
is_disciplina=find(strcmp(disciplina_dimissione,'')==1);
is_reparto=find(strcmp(prog_reparto,'')==1);
is_ricovero=find(strcmp(regime_ricovero,'')==1);
is_provenienza=find(strcmp(provenienza,'')==1);
is_drg=find(strcmp(drg,'')==1);
[...]
end
handles.anno_tr=anno;
handles.azienda_tr=azienda;
handles.istituto_tr=istituto;
[...]
handles.ints3_tr=int_sec3;
handles.ints4_tr=int_sec4;
handles.modacc_tr=mod_accesso;
handles.moddim_tr=mod_dimissione;
handles.tric_tr=tipo_ricovero;
handles.ding_tr=data_ingresso;
handles.tpres_tr=tipo_prescrittore;
handles.codnos_tr=cod_nos;
guidata(hObject,handles);
%delete(wb);
%wb=waitbar(0.8, 'Loading... 80%');
% VISIBILITA'
set(handles.ET_Percorso, 'visible', 'off');
set(handles.PB_Sfoglia, 'visible', 'off');
set(handles.PB_Carica, 'visible', 'off');
set(handles.PB_LeggiNuovo, 'visible', 'on');
set(handles.PB_Rit_Ist, 'visible', 'off');
[...]
%set(handles.ET_ICM, 'visible', 'on');
%set(handles.ET_ICP_AN, 'visible', 'on');
%set(handles.ET_ICM_AN, 'visible', 'on');
%set(handles.ET_Classifica_ICP, 'visible', 'on');
% set(handles.ET_Classifica_ICM, 'visible', 'on');
% set(handles.ET_Differenza_ICP, 'visible', 'on');
% set(handles.ET_Differenza_ICM, 'visible', 'on');
% set(handles.PB_Calcola, 'visible', 'on');
set(handles.G1_Grafico, 'visible', 'on');
%set(handles.ST_Panel, 'visible', 'on');
%delete(wb);
%wb=waitbar(1, 'Loading... 100%');
%delete(wb);
global UNI
UNI=unique(istituto);
GUI1('init');
set(handles.PM_Menu, 'Enable', 'on');
THANKS A LOT! - I erased some lines... ;)

Kategorien

Mehr zu Dialog Boxes finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by