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

2 views (last 30 days)
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...

Accepted Answer

Jethro
Jethro on 9 Dec 2011
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 Comments
Image Analyst
Image Analyst on 9 Dec 2011
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 on 6 Mar 2013
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...

Sign in to comment.

More Answers (3)

Walter Roberson
Walter Roberson on 7 Dec 2011
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 Comments

Sign in to comment.


Sean de Wolski
Sean de Wolski on 7 Dec 2011
how about using:
dbstop if error
to stop at the line that returns the error?
  2 Comments
Jethro
Jethro on 7 Dec 2011
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 on 7 Dec 2011
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.

Sign in to comment.


Image Analyst
Image Analyst on 7 Dec 2011
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 Comments
Jethro
Jethro on 9 Dec 2011
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 on 9 Dec 2011
Please check out the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.3F

Sign in to comment.

Categories

Find more on Environment and Settings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!