필터 지우기
필터 지우기

warning for not filled fields in guide

조회 수: 1 (최근 30일)
Radoslav Vandzura
Radoslav Vandzura 2015년 11월 8일
댓글: Image Analyst 2015년 11월 9일
Hello All,
I would like to ask you how can I make warning for not filled fields in guide? I want when someone doesnt fill fields, warning will appear at the screen? How should I do it?

채택된 답변

Image Analyst
Image Analyst 2015년 11월 8일
You have to get the fields that you want to check, then use isempty() or length() or something to see if there is anything there
editField = get(handles.edit1, 'String');
if isempty(editField)
message = sprintf('Warning: edit1 is not allowed to be empty!');
uiwait(warndlg(message));
end
  댓글 수: 2
Radoslav Vandzura
Radoslav Vandzura 2015년 11월 8일
Is any way according can I do it together for all fields?
Image Analyst
Image Analyst 2015년 11월 9일
You're sort of doing it right - once for every field. After all, it's a GUI and there will be just a small, finite number of fields - it's not like there will be thousands of them.
One thing you're doing wrong however is passing the result of get() into str2num(). If the field is empty that will most likely cause an ugly error. It's better to check first and present the user with "friendly" instructions like in my code.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by