Periodically Updated Static Text and Reading from Key-Value File
1 回表示 (過去 30 日間)
古いコメントを表示
I have two questions concerning a GUI application I'm writing:
- Is it possible to code a static text label so it periodically updates itself (from a database, or whatever) without interfering with the execution of the main application? The label would be used to cycle through news, updates, etc. That sort of thing.
- Currently, my application sets user-supplied variables by running a script, generate_appvars. I'll be compiling soon, but want to preserve this method of reading in run params at runtime. I was thinking a key-value params file which I can read into a dynamically named struct, but am unsure of how to handle vector and cell assignments (k/v pairs key = [1, 3, 5] or key = {'this', 'that'} for instance). Thinking of using eval for the right hand assignment, but don't think it's the best solution. How do other people handle runtime parameters like this?
Thanks!
0 件のコメント
採用された回答
Fangjun Jiang
2011 年 9 月 22 日
For 1, you can probably use a timer object and set up the callback to refresh your text label.
For 2, you can use the parameter file to specify your key-value pairs:
par1, 1
par2, 2
par3, 3
After reading in the files, try to organize the data as:
Keys={'par1','par2','par3'}; Values={1,2,3};
Then run
a=cell2struct(Values,Keys,2)
You will get a.par1, a.par2, a.par3 holding the correct value and you've avoided the notorious evil eval.
0 件のコメント
その他の回答 (2 件)
Walter Roberson
2011 年 9 月 22 日
1. No -- background activity always interferes with the execution of the main application.
Perhaps for your purposes it would be acceptable to code a timer whose callback fetched the data and set() the text control to the new content.
2. regexp() can help with the parsing -- though matching apostrophes can be a pain if your strings are allowed to include apostrophes.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で MATLAB Compiler についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!