Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

What is the problem in the code? I am using R2011a

2 visualizaciones (últimos 30 días)
Sameer
Sameer el 4 de Mzo. de 2014
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Undefined function or variable 'myname'.
Error in ==> SAM_1>pushbutton1_Callback at 82 if (length(myname) ~= NULL) && (length(mypass) ~= NULL)
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> SAM_1 at 42 gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)SAM_1('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
MY CODE IS :
function pushbutton1_Callback(hObject, eventdata, handles) handles = guidata(hObject); if (length(myname) ~= NULL) && (length(mypass) ~= NULL) open('hr.jpg'); end guidata(hObject,handles);
function uname_Callback(hObject, eventdata, handles) handles = guidata(hObject); handles.myname = get(hObject,'String'); guidata(hObject,handles);
function tpass_Callback(hObject, eventdata, handles) handles = guidata(hObject); handles.mypass = get(hObject,'String'); guidata(hObject,handles);

Respuestas (1)

dpb
dpb el 4 de Mzo. de 2014
Please format your code so I don't have to... :(
function pushbutton1_Callback(hObject, eventdata, handles)
handles = guidata(hObject);
if (length(myname) ~= NULL) && (length(mypass) ~= NULL)
open('hr.jpg');
end
guidata(hObject,handles);
function uname_Callback(hObject, eventdata, handles)
handles = guidata(hObject);
handles.myname = get(hObject,'String');
guidata(hObject,handles);
function tpass_Callback(hObject, eventdata, handles)
handles = guidata(hObject);
handles.mypass = get(hObject,'String');
guidata(hObject,handles);
I don't do GUIs so I don't "know nuthink" about the callbacks and the objects but you refer to a variable myname in the pushbutton1_Callback function whereas the uname_Callback function stuffs it into the handles object as a named field.
Whether the right object is getting passed or not is at a deeper level thatn I know; only that you'll have to refer to it as handles.myname to retrieve it...

La pregunta está cerrada.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by