Five9dak
Mechanical
- Nov 28, 2006
- 11
I am trying to modify a variable Tbread inside a radio button call back. Here is the important parts of the code I have.
I get this error:
??? Undefined function or variable "Tbread".
Error in ==> ElectronPizza>radiobutton1_Callback at 186
Tbread=Tbread-2
Error in ==> gui_mainfcn at 75
feval(varargin{:});
Error in ==> ElectronPizza at 27
gui_mainfcn(gui_State, varargin{:});
??? Error using ==> ElectronPizza('radiobutton1_Callback',gcbo,[],guidata(gcbo))
Undefined function or variable "Tbread".
??? Error while evaluating uicontrol Callback
How do I properly allow this callback to work with this variable? Other callbacks will also be modifying it in a similar manner. Thanks in advance
Code:
function variable()
global Tbread;
Tbread=0;
end
% --- Executes on button press in radiobutton1. 7.50 MEDIUM PIZZA
%medium pizza: 7.50 dollars: 2 bread: 2 suace: 2 cheese
function radiobutton1_Callback(hObject, eventdata, handles)
if (get(hObject,'Value') == get(hObject,'Max'))
% Radio button is selected-take approriate action
Tbread=Tbread-2
Tsauce=Tsauce-2
Tcheese=Tcheese-2
total=total+7.50
else
% Radio button is not selected-take approriate action
Tbread=Tbread+2
Tsauce=Tsauce+2
Tcheese=Tcheese+2
total=total-7.50
end
end
I get this error:
??? Undefined function or variable "Tbread".
Error in ==> ElectronPizza>radiobutton1_Callback at 186
Tbread=Tbread-2
Error in ==> gui_mainfcn at 75
feval(varargin{:});
Error in ==> ElectronPizza at 27
gui_mainfcn(gui_State, varargin{:});
??? Error using ==> ElectronPizza('radiobutton1_Callback',gcbo,[],guidata(gcbo))
Undefined function or variable "Tbread".
??? Error while evaluating uicontrol Callback
How do I properly allow this callback to work with this variable? Other callbacks will also be modifying it in a similar manner. Thanks in advance