필터 지우기
필터 지우기

Keep the variable of ediTtext if you don't change it

조회 수: 1 (최근 30일)
Abel Romero
Abel Romero 2017년 12월 2일
댓글: Image Analyst 2017년 12월 2일
Hello, I want to do a GUI that have 4 editText, 1 pushbutton and 1 table. I want to put the info of the editText in the table. When I put the values in the editText and I push the button, it puts in the table. If I don't change anything and I push the button, the gui don't catch the values of the editText. If I change the values all the time I don't have this problem.
  • Example: I put the values 4 5 6 7 into the text box
  • I hit the button (the values get put into the table)
  • I hit the button without changing the values (Here is my problem!)

답변 (1개)

Image Analyst
Image Analyst 2017년 12월 2일
What is the code in the callback for the push button? If it extracts the edit text string, and parses it, and puts it into the table, it will work regardless if the text has been changed or not. It simply works on the current string in the edit text box.
  댓글 수: 2
Abel Romero
Abel Romero 2017년 12월 2일
Ignore the functions, when i hit the button two times without changing the variables it does not put in the table.
function addElement_Callback(hObject, eventdata, handles)
% hObject handle to addElement (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global label value fnode lnode
[handles.E, handles.countElement]=add_Element( handles.E,handles.countElement,label,value,fnode,lnode );
[handles.c,handles.t,handles.v,handles.fn,handles.ln,handles.btn]=addInfo(handles.countElement,handles.E);
handles.datos=get(handles.uitable1, 'Data');
label=cellstr(label);
value = num2cell(value);
fnode=num2cell(fnode);
lnode=num2cell(lnode);
if isempty(handles.datos)
handles.datos(1,1)=label;
handles.datos(1,2)=value;
handles.datos(1,3)=fnode;
handles.datos(1,4)=lnode;
else
handles.datos(end+1,1)=label;
handles.datos(end,2)=value;
handles.datos(end,3)=fnode;
handles.datos(end,4)=lnode;
end
set(handles.uitable1,'Data',handles.datos);
guidata(hObject,handles);
Image Analyst
Image Analyst 2017년 12월 2일
set a breakpoint in that function. Does it step on the same lines of code in the two cases? What are the values of the variables? Just do normal debugging and you should be able to figure it out.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by