I was hoping to be able to get a control reference datatype from just the control/indicator label name. Attached is an image that shows I am able to get the current value of a control by inputting the control name, but I want the control reference so I can change properties of the said control/indicator.
Solved! Go to Solution.
You can get a property node for the pane and get the "controls" property, which is an array of all control references. Now iterate over it using an autoindexing FOR loop and check the label for each. The one resulting in the correct label is the reference you want. (you might need to cast it to more specific later).
Can you explain the usefulness of this exercise? Seems fragile and convoluted (for example if you later accidentally change the label (maybe there is a spelling error), you would need to make matching changes in other parts of the code).
Edit: Sorry I did not see the second part of your answer. I was planning to use this method to store different language descriptions for various controls and indicators in a SQL database. I would store the control/indicator's name and data type (boolean, int, etc..) this would allow me to change the language on the fly. I like this approach because I have multiple controls/indicators that have the same name (in different screens and different machines) so this allows me to use the same entry (i.e. run, start, stop, reset are commonly used throughout different screens and linked machines).
I was planning to use this method to store different language descriptions for various controls and indicators in a SQL database. I would store the control/indicator's name and data type (boolean, int, etc..) this would allow me to change the language on the fly.
I am not sure what you mean by "on the fly", but to localize a program, we also have this.
Thank you for sharing this, I did not know it existed. It is essentially what I am working towards with a few caveats:
1) I have quite a few user messages that will grow over time and I believe keeping them on a database is a better solution for managing them (multiple machines, read multiple deployed applications will be accessing this database).
2) I want to be able to press a button and have the language change in runtime, this is what I meant by on-the-fly.
3) By using the database method, I can easily add an additional language pack without ever touching the deployed applications. I have a drop down menu that is a text ring and searches for languages.
4) In the same database I also store access levels, this will disable controls based on who is logged in.
5) We also develop applications in other software environments, so a database is more agnostic in the sense we could potentially reuse it.