Periodically Updated Static Text and Reading from Key-Value File
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Fangjun Jiang
am 22 Sep. 2011
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 Kommentare
Weitere Antworten (2)
Walter Roberson
am 22 Sep. 2011
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 Kommentare
Siehe auch
Kategorien
Mehr zu MATLAB Compiler finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!