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.
PLC sets interger variable iStatus
Range of iStatus 0-100
Define localisation variables "Status000" - "Status100"
Status000: "Stopped"
Status001: "Prepering"
Status002: "Running"
:
Status100: "Done"
Define and use function localize (see article Integer-in-hex-notation )
/**
* 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") + "}")
}
... View more