From: Christian on
Hi,

I am trying to pass variables from one callback function to another. I appear to be able to do this with a pushbutton callback function but not with an text callback function.

My code looks like:

%Obtains a list of preferences from a drop down menu
function edit1_Callback(hObject, eventdata, handles)
%From a function the string 'moderate' is obtained
%so the string value of the preference = moderate
handles.pref = preference
guidata(gcbo, handles);

%Now for passage to the next callback function using the text
function text1_Callback(hObject, eventdata, handles)
preference = handles.pref
%for the next computation and passage to the push button callback function
guidata(gcbo, handles);

Equally the strings could be numeric values, however I am not having any luck with either method. I have read a little about nested functions - could this be the case? If so could you lay out an example please - some of this is relatively new to me.

Thanks in advance for your help.
Christian
From: Matt Fig on
I think you may need to look at the help for GUIDATA. To store data, use two arguments. To retrieve data, use one.

Also, you may want to have a look at the tutorials:

http://www.mathworks.com/matlabcentral/fileexchange/24861-41-complete-gui-examples
From: Christian on
Hi Mat

Thanks for this but using GUIDE do you have any other clues as to my problem. Read through the GUIDATA help and was slightly familiar with this.

Cheers
Christian

"Matt Fig" <spamanon(a)yahoo.com> wrote in message <huu2kc$us$1(a)fred.mathworks.com>...
> I think you may need to look at the help for GUIDATA. To store data, use two arguments. To retrieve data, use one.
>
> Also, you may want to have a look at the tutorials:
>
> http://www.mathworks.com/matlabcentral/fileexchange/24861-41-complete-gui-examples