08/12/2011 - I need more answers about: "Attempt to reference field of non-structure array" error
이전 댓글 표시
Hi... I'm creating a project with different windows linked by PushButtons... In one of them, I set a login... When I run the login window, it runs perfectly, but when I start from the first, I have an error:
??? Attempt to reference field of non-structure array.
Error in ==> Login_Page_IT>ET_LOG_IT_Callback at 81
username=(get(handles.ET_LOG_IT, 'String'));
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> Login_Page_IT at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)Login_Page_IT('ET_LOG_IT_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
I post you the code...
function ET_Log_EN_Callback(hObject, eventdata, handles)
username = get(handles.ET_Log_EN, 'String');
checkuseren(username);
checkuseren function code is:
function checkuseren(username)
if length(username) ~= 7
e_msg=msgbox('Personal Code needs 7 characters!', 'ERROR: PERSONAL CODE', 'error');
end
[USER PWD CF NAME SURNAME]=textread('Login.txt', '%s %s %s %s %s', 'headerlines', 1, 'delimiter', '\t');
flag=find(ismember(USER,username));
if flag
else
e2_msg=msgbox('ACCESS DENIED! Personal Code is not in the DB or is uncorrect!', 'ERROR: PERSONAL CODE', 'error');
end
I can't understand WHY the window runs if I load it, but it doesn't if I start my program by the first window...
EDIT: THE ERROR IS ABOUT
username = get(handles.ET_Log_EN, 'String');
I checked syntax and all names I gave, I wrote it correctly...
채택된 답변
추가 답변 (3개)
Walter Roberson
2011년 12월 7일
0 개 추천
Exactly how are you starting the first one?
Are you double-clicking on a .fig file to launch it? If so then that does not work: you must instead run the .m file with the same name as the .fig file.
댓글 수: 4
Jethro
2011년 12월 7일
Andrew
2012년 7월 19일
-No idea if this wil be read but... I am running into a similar issue, but i want to create a stand alone app with my gui. I believe it runs into the same problem as running only the .fig file. Do you know why running the .fig file won't execute the program correctly/completely?
Walter Roberson
2012년 7월 19일
The .fig file has no way to call the initialization routines that are in the .m file.
Andrew
2012년 7월 19일
편집: Walter Roberson
2012년 7월 19일
thanks for the answer. i guess its just my code then =(
Sean de Wolski
2011년 12월 7일
how about using:
dbstop if error
to stop at the line that returns the error?
댓글 수: 2
Jethro
2011년 12월 7일
Sean de Wolski
2011년 12월 7일
it't trying to access a the field ET_Log_EN of the structure handles. Idf handles isn't a structure, you'll see the error you're seeing.
whos handles
when the debugger stops.
Image Analyst
2011년 12월 7일
0 개 추천
Why are you trying to set the caption/label of your pushbutton as the username? set a breakpoint there. If you hover over handles, does it popup a list of members that the handles structure has? If so, is ET_Log_EN one of them? Remember, MATLAB is case sensitive.
댓글 수: 4
Jethro
2011년 12월 7일
Image Analyst
2011년 12월 9일
Sorry - I don't know what this means: "I set login because more then an user can analyze the file in different ways". I also don't know what these 5 windows are. Are they "figures" (that's MATLAB lingo) and your main program (which I think is a GUIDE GUI) goes through a series of 4 or 5 figures in turn before it gets to your login figure?
Jethro
2011년 12월 9일
Image Analyst
2011년 12월 9일
Please check out the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.3F
카테고리
도움말 센터 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!