prompt a GUI user to enter different values

조회 수: 4 (최근 30일)
Rich006
Rich006 2023년 4월 19일
댓글: Adam Danz 2023년 4월 20일
I am using App Designer to write a GUI wrapper for an existing app. The app should load some data based on the user input. If the user input is invalid, how can I make the user try again? For example, the user entered an end time that is not after the previously entered starting time. Or as a simpler example, the user entered a string that is not one of the valid responses.

채택된 답변

Adam Danz
Adam Danz 2023년 4월 19일
Put your dialog in a while-loop that exits when the input conditions are met and regenerates the dialog if the conditions are not met.
Here is an example using input() which generates a prompt in the command window rather than generating a dialog but it would follow the same general process (dialogs are much better than input()).
  댓글 수: 4
Rich006
Rich006 2023년 4월 20일
The whole purpose of the app is to get input from the user (start date, start time, end date, and end time plus three other values), and then call a function with those values as arguments. Maybe I don't even want a full-on App, but just a few input dialogs wrapped in a script with validation. I was thinking I wanted one dialog for all seven inputs, with validation happening within the dialog, but that's probably not the best approach. This should be as simple as possible, but no simpler. :-)
Adam Danz
Adam Danz 2023년 4월 20일
I see. That makes sense. You could create a dialog or an app, inputdlg might come in handy.
Let's say you're using inputdlg. Create it within a while-loop that creates the dialog, validates the users's input, and either leaves the loop or continues for another iteration.
It will look something like this.
inputsGood = false;
while ~inputsGood
response = inputdlg(___);
inputsGood = myValidation();
end

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by