reading edit boxes without callback

2 views (last 30 days)
Everybody hello, my question about to read edit boxes(~10) without call backs, because of the number of edit boxes and also the default values are difficult to enter every time when I run the GUI, default values are already exist in the editboxes so when user wants to change any, with callback function I can read the values but now I want to store all data without any callback of edit box but just callback function of pushbutton. because on that case when the subfunctıon of pushbotton is called as the variables in the handle has not beed defined yet I can't store the data what is the best way to get all those data from written editboxes without calling exucitıon of the subfunction blongs to edit boxes. thanks ın advance

Accepted Answer

Image Analyst
Image Analyst on 30 Aug 2013
The edit boxes don't need to have any callbacks. In the callback of your pushbutton, simply get their values and do whatever you want with them, such as save them to a file or use them in a calculation or expression.
function pushbutton__Callback(hObject, eventdata, handles)
text1 = get(handles.editBox1, 'String');
text2 = get(handles.editBox2, 'String');
text3 = get(handles.editBox3, 'String');
text4 = get(handles.editBox4, 'String');
text5 = get(handles.editBox5, 'String');
text6 = get(handles.editBox6, 'String');
text7 = get(handles.editBox7, 'String');
text8 = get(handles.editBox8, 'String');
text9 = get(handles.editBox9, 'String');
text10 = get(handles.editBox10, 'String');
  3 Comments
Azzi Abdelmalek
Azzi Abdelmalek on 30 Aug 2013
No, put them all, in the callback of your pushbutton
Image Analyst
Image Analyst on 31 Aug 2013
Like Azzi and I said, put them in the callback of the pushbutton. You CAN read them in the callback of the editbox, but that doesn't help you because when you push the pushbutton, you still need to retrieve their values in the pushbutton's callback anyway, and the easiest way to do that is by calling get() with the edit boxes' handles. So don't bother putting anything at all in the edit field callbacks - I never put anything in there with my edit boxes. It doesn't do you any good there.

Sign in to comment.

More Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 30 Aug 2013
data{1}=get(handles.editbox1,'string');
data{2}=get(handles.editbox2,'string');
data{3}=get(handles.editbox3,'string');
What is the problem with that?

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!