Wait for app to close before continuing with script

조회 수: 111 (최근 30일)
Fernando
Fernando 2020년 11월 16일
댓글: Mario Malic 2021년 6월 17일
Hi,
I'm a newb to using App Designer. I've built the GUI that works wonderfully, and can open it programmatically from my main .m script. However, I cannot for the life of me figure out how to force the .m script to wait for the App GUI to close. I figure it has something to do with assigning modality in App Designer. I've tried using a waitfor indexing with a variable written to my base workspace from the app to no avail. I've tried using a while condition, also to no avail. Are there any ways to make the main script wait for the app to close before continuing?

채택된 답변

Mario Malic
Mario Malic 2020년 11월 16일
Hello Frankie,
Here's an example how to do it.
app = NameOfApp;
while isvalid(app); pause(0.1); end
  댓글 수: 8
Rauf Iftikhar
Rauf Iftikhar 2021년 6월 17일
no the figure opens at that command and closes on the CloseRequestFcn
Mario Malic
Mario Malic 2021년 6월 17일
If it's made by guide and can be detected by gca, you can try with the code below, otherwise, see step 2 of this answer
fig = gca;
if isvalid(fig)
waitfor(fig);
end
You can try removing CloseRequestFcn, write a public function so you could close it in your script.

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

추가 답변 (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