FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
03-07-2023 03:23 PM
Hello,
I am trying to use the MAP function to convert an INT value to text and display this with an label.
However, I am a bit lost. I cannot seem to get it working.
My localized text looks like this:
My label looks like this:
This doesnt work, the label still shows the INTvalue:
Is it possible what I am trying to do and if yes what am I doing wrong?
Thank you in advance!
Solved! Go to Solution.
03-07-2023 04:00 PM
There's no need to do some complex mapping which doesn't even work there as you seem to assume behavior that is not documented and neither intended nor working in that area. The map function is defined in "15.3.3. Use Of Numeric Status Info In Alarm Texts" in the manual and as such works with alarms texts, but this is not an alarm text.
The correct way with WebIQ would to be setup the options in the IQ Label widget you're already using to map the values to texts/localizations.
03-08-2023 08:39 PM
Thank you!
I was not aware that I could do it that way.
It works perfecty!
03-09-2023 09:33 AM
There is also another possibility, which is especially interesting when it is necessary to convert a lot of numbers into texts.
e.g. If the PLC sends status messages as numbers, which should be displayed as text in the active language.
/**
* returns the translation for the localization variable whose name is created dynamically
* @param {string} sPrefix
* @param {int} iValue
* @returns translation text defined by inputs
* @example
// java script
console.log(cxt.localize("state", 1)) // returns value of localization var: state001
// usage in iq-text where items[0] is an integer
<%= localize("state", items[0].value) %>
*/
localize(sPrefix, iValue) {
return shmi.localize("${" + sPrefix + ("" + iValue).padStart(3, "0") + "}")
}