Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
togglebutton with togglebutton inside for afteruse control
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
hi, I have a problem when dealing with toggle button control. I use one togglebutton2 to deside whether the mechine is on or off after use. togglebutton1 to control the system runing or stop. When the togglebutton1 value = 0, it should read the value of togglebutton2 to decide the mechine is on or off. But the command line just show
Error using handle.handle/get
Invalid or deleted object.
Error in pump_Callback (line 152)
if get(GUI.tot+28, 'value') == 1
Error while evaluating UIControl Callback.
my codes are
if get(togglebutton1, 'value') ==0
set(hObject,'BackgroundColor',GUI.menucolor,...
'string',[get(hObject, 'UserData') ' stopped'],'FontSize',8);
if check == GUI.tot+5 %the value control speed
GUI.p1Running = 0;
if get(togglebutton2, 'value') == 1
stop(p1.t);
vc = vc_set_bits_ac(vc, p1.num, [0 0 0 0 0 0]);
elseif get(togglebutton2, 'value') == 0
stop(p1.t);
vc = vc_set_bits_ac(vc, p1.num, [0 0 0 0 0 0]);
end
end
end
But the code can work well when they are the following one. How can I do? Please Help! Very Thank!
if get(togglebutton1, 'value') ==0
set(hObject,'BackgroundColor',GUI.menucolor,...
'string',[get(hObject, 'UserData') ' stopped'],'FontSize',8);
if check == GUI.tot+5 %the value control speed
GUI.p1Running = 0;
stop(p1.t);
vc = vc_set_bits_ac(vc, p1.num, [0 0 0 0 0 0]);
end
end
1 commentaire
Jan
le 20 Déc 2018
The line if get(GUI.tot+28, 'value') == 1 occurs in the error message, but not in the shown code. Please post the code, you are actually running, not any otehr code.
Are you sure that GUI.tot+28 is meaningful? We cannot know, what the variables check and GUI.tot are.
Réponses (1)
Cris LaPierre
le 20 Déc 2018
Modifié(e) : Cris LaPierre
le 20 Déc 2018
I'm with Jan. Your error is coming from code you have not shared.
if get(GUI.tot+28, 'value') == 1
The get function expects the first input to be an object. Basically, a handle to an object. It would appear from your code GUI.tot is a number and not an object handle. So the error is that it cannot find the specified object because either your object handle is invalid or the object has been deleted.
A more typical expression would be
if get(togglebutton1, 'value') == 1
2 commentaires
Walter Roberson
le 22 Déc 2018
Better to post the actual code.
If you are running R2014a or earlier, then GUI handles are numeric, and adding a number to them would create another numeric value. It is valid in those releases to get() passing in a numeric value -- it is just that the result would seldom just happen to be another valid object handle. It is not impossible to build a situation in those releases such as
GUI.tot = figure(); GUI.fig2 = figure(GUI.tot+35);
but it is seldom a good idea.
Cette question est clôturée.
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!