フィルターのクリア

Share global variables between windows App Designer

12 ビュー (過去 30 日間)
Iacopo
Iacopo 2022 年 6 月 23 日
コメント済み: Jan 2022 年 6 月 24 日
Hi all,
I'm pretty new to App Designer. I designed a 2-windows software and would like to trasfer a global variable created in one of the 2 windows to the other one, setting it as global in there as well. Does any of you if this is possible?
The window where the variable was created as global let me transfer a variable with prefix "app." (that is a global variable), but the StartUp function of the receiving window does not take the prefix, so I am obliged to set the same variable in the receiving window as local.
Thanks in advance for your help!

採用された回答

Jan
Jan 2022 年 6 月 23 日
編集済み: Jan 2022 年 6 月 24 日
Global variables are a mess in every case. Sending the data through a well defined interface would be much better.
Do not use "app" as name of a global variable, because this variable occurs in both programs. Sharing them would crash the GUIs. But you can select another name, preferrably a name, which does not occur anywhere else as "sharedBetweenTheGUIs". Declare it as global in both applications and then defining it in one GUI makes it available in the other also.
Except if you are talking about compiled applications. Do you run the GUIs inside a Matlab session?
  2 件のコメント
Iacopo
Iacopo 2022 年 6 月 23 日
Thanks Jan for your help! Yes I'm running my software inside a Matlab session
Jan
Jan 2022 年 6 月 24 日
Then it is safer to use finobj() to search the other GUI and to write the data directly to it, e.g. by setappdata. A specific function of the other GUI to provide data would be even smarter.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop 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