08/12/2011 - I need more answers about: "Attempt to reference field of non-structure array" error

조회 수: 1 (최근 30일)
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...

채택된 답변

Jethro
Jethro 2011년 12월 9일
I checked the FAQ but I didn't find anything useful for me... I post the whole error message... Can someone help me??
==================
I solved my problem using "figure()"
  댓글 수: 2
Image Analyst
Image Analyst 2011년 12월 9일
Why don't you just have a single GUI for everything. Then you can just pass around the handles structure and everything is simple. Right now you have lots of disconnected figures popping up all over the place making a cluttered mess. What's more, a new figure is not going to know the handles of some prior figure, or even a later figure unless you do some complicated stuff. Just use GUIDE and make a single GUI. If you want you can set the visible property of some controls on or off to show or hide them. It would just be a lot easier if you did that.
kapil
kapil 2013년 3월 6일
i am processing a value from a text box, when i click a button, and it is showing the same error as in "Attempt to reference field of non-structure array"... Can You Help me...

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

Walter Roberson
Walter Roberson 2011년 12월 7일
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
Walter Roberson
Walter Roberson 2012년 7월 19일
The .fig file has no way to call the initialization routines that are in the .m file.
Andrew
Andrew 2012년 7월 19일
편집: Walter Roberson 2012년 7월 19일
thanks for the answer. i guess its just my code then =(

댓글을 달려면 로그인하십시오.


Sean de Wolski
Sean de Wolski 2011년 12월 7일
how about using:
dbstop if error
to stop at the line that returns the error?
  댓글 수: 2
Jethro
Jethro 2011년 12월 7일
I used the code, and it shows me the same line where I had the problem...
username = get(handles.ET_Log_EN, 'String');
I didn't write it, what an idiot I am lol
Sean de Wolski
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
Image Analyst 2011년 12월 7일
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
Jethro 2011년 12월 9일
Yes, they are all figures, made by gui, and, Yes there's some figures before my login figure...
I think I have to "generalize" handles but it's only an hyp...
In short...
Figure 1: Select Language ->
Figure 2: Software introduction ->
Figure 3: Login -> Figure 4.1 User #1 fig
-> Figure 4.2 User #2 fig
-> Figure 4.3 User #3 fig
Image Analyst
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by