フィルターのクリア

How to indicate there was an error in the code in App designer stand alone app?

5 ビュー (過去 30 日間)
Sveta Golod
Sveta Golod 2021 年 2 月 3 日
コメント済み: Sveta Golod 2021 年 2 月 7 日
I have some GUI that I created in app designer.
When something wrong (for example I loaded a file with wrong format) - I get an error in the app designer.
But in stand alone app - I can't see the error and can't see any indication that there was an error.
I cannot predict all possible errors.
But I want to see the error text in the stand alone app. Is there some way to show it?
  2 件のコメント
Adam
Adam 2021 年 2 月 3 日
編集済み: Adam 2021 年 2 月 3 日
If you tell it to create a log file when you compile the app you will see it there. Or if you run from command line it will also show there. But if you want it to show actually in your app, on the UI, that's not so easy.
Sveta Golod
Sveta Golod 2021 年 2 月 3 日
Thanks for your answer.
Is there a way to get the log file content into the GUI, i.e. put the text from log into text area?
Or is there any way to indicate for the user that the code didn't run and something is wrong? Like putting a red lamp or something?

サインインしてコメントする。

回答 (1 件)

Mario Malic
Mario Malic 2021 年 2 月 3 日
編集済み: Mario Malic 2021 年 2 月 3 日
Hello,
As Adam said, it's not so easy. You can use a TextArea and Button component to trigger the callback to load the logfile in the text area. You'll need to figure out how to get the file path of log file. The fact that you have to click the button to load the file is not the best way, maybe you could do it with ButtonDownFcn callback, with every click to load the log file which is still not the best solution.
function ReadCmdWindow(app)
cmdWindowString = fileread('logfile.txt');
app.CommandWindowOutputTextArea.Value = cmdWindowString;
end
If you want to click a button that runs something, and there are prerequisites that needs to be fullfilled, like a value in the EditField component. You can write if statement that checks if some entries are missing, show an alert with uialert function.
Also, you can pop the warning/errors using try and catch with uialert. It works really nice. If you have Optimization toolbox, you can check my uioptimoptions to see the uialerts.

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by