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...

 Respuesta aceptada

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 comentarios

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.
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...

Iniciar sesión para comentar.

Más respuestas (3)

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 comentarios

No, I open my .m file and I run it...
-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?
The .fig file has no way to call the initialization routines that are in the .m file.
thanks for the answer. i guess its just my code then =(

Iniciar sesión para comentar.

how about using:
dbstop if error
to stop at the line that returns the error?

2 comentarios

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
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.

Iniciar sesión para comentar.

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 comentarios

Yes, I know Matlab is CS and ET_Log_EN (means EditText_Login_English) it's the tag I used for the Edit Text. With my function, I'm trying to check the length and the existence of my username, according to a pre-existend database (a .txt file I read with textread in the function).
I can't set a list of members, because my university progect is to create a software that can analyze a particular file. I set login because more then an user can analyze the file in different ways. So, I need to set it like I'm doing...
My problem is:
EXAMPLE, The window in question is number 5.
If I run window 5, it runs correctly.
If I start by window 1, I arrive at window 5 and my program breaks...
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?
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
Please check out the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.3F

Iniciar sesión para comentar.

Categorías

Más información sobre Interactive Control and Callbacks en Centro de ayuda y File Exchange.

Preguntada:

el 7 de Dic. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by