There is another way, with the iq-text element which support the execution of JS functions.
Define a Local-Script "Globals" where you can place all your global JS functions, variables and constants.
Remove code, which is automatically created
Insert code /**
Converts an interger number to a HEX string
* @example
* x = Int2Hex(255, 4)); // x = "00FF"
*
* @param {number} iVal Number to convert
* @param {number} iLen length of converted string
* @returns {string} HEX string of iVal
*/
function Int2Hex(iVal, iLen) {
return iVal.toString(16).toUpperCase().padStart(iLen, "0");
}
/**
* Converts iVal into binary string
* @example
* x = Int2Bin(3, 4)); // x = "0011"
*
* @param {number} iVal Number to convert
* @param {number} iLen length of converted string
* @returns {string} HEX string of iVal
*/
function Int2Bin(iVal, iLen) {
return iVal.toString(2).padStart(iLen, "0");
}
Insert a iq-text with the INT item to display as HEX number
Not working with virtual items
To display Hex: Insert text: <%= Int2Hex(items[0].value,6) %>
To display Bin: Insert text: <%= Int2Bin(items[0].value,6) %>
... View more