08/12/2011 - I need more answers about: "Attempt to reference field of non-structure array" error
Afficher commentaires plus anciens
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...
Réponse acceptée
Plus de réponses (3)
Walter Roberson
le 7 Déc 2011
0 votes
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 commentaires
Jethro
le 7 Déc 2011
Andrew
le 19 Juil 2012
-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
le 19 Juil 2012
The .fig file has no way to call the initialization routines that are in the .m file.
Andrew
le 19 Juil 2012
Modifié(e) : Walter Roberson
le 19 Juil 2012
thanks for the answer. i guess its just my code then =(
Sean de Wolski
le 7 Déc 2011
how about using:
dbstop if error
to stop at the line that returns the error?
2 commentaires
Jethro
le 7 Déc 2011
Sean de Wolski
le 7 Déc 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.
Image Analyst
le 7 Déc 2011
0 votes
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 commentaires
Jethro
le 7 Déc 2011
Image Analyst
le 9 Déc 2011
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
le 9 Déc 2011
Image Analyst
le 9 Déc 2011
Please check out the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.3F
Catégories
En savoir plus sur Interactive Control and Callbacks dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!