An interesting question from a customer came in that went something like this (I love that he gave lots of details/background so I easily get the big picture, and in this case, go in a different direction than his initial question).
At what point does a string table set as “persistent” lose its data? … I have a multi-language interface [using] two string tables stEnglish and stPORTUGESE [and] a numeric variable called nLANGUAGE… I use a button to toggle the bit in nLANGUAGE from 0 to 1.
I then have alternating visible labels which each look at the respecting table and become visible based on the bit. So initially, ENGLISH shows, then once the button is pushed the toggle sets the language to PORTUGESE. All of this works great. (if there’s a better way to toggle text from engine, PLEASE let me know)…
Should I initialize the table via hard code?
To answer his final question first, I’d say: “yes, hard-code those tables.” This is based on an assumption that he won’t need to be changing these table values very often or on-the fly. (Of course, with PAC Project you have many options for initializing and/or changing variables.)
Assuming he takes this suggestion, he won’t need to use persistent memory – which gets wiped out (as documented in form 1700, chapter 9) when:
- A strategy with a different name is downloaded.
- The RAM memory on the controller is cleared.
- A new firmware kernel is downloaded to the controller.
- The persistent object is changed (modified table length/width, etc.)
He also asked if there was a “better way to toggle text.” I’d suggest have PAC Display (or even groov) use just one string table, which gets swapped out if/when the language is changed.
Why would I do it this way? Two main reasons:
- Easier to build your HMI – time is money, let your PAC do the heavy lifting and keep your HMI simple.
- Today you support 2 languages, hopefully your product will be in-demand world-wide and you’ll want to support 20 (or 200!) languages in the future.
That’s my short answer, a couple other considerations to follow…