Generating sting tag from ascii code of its characters

Hello
I have 4 byte tags that contain values like:
TEST_BYTE_1 = 53
TEST_BYTE_2 = 48
TEST_BYTE_3 = 71
TEST_BYTE_4 = 70

these are ascIi codes of a chars 5, 0, G, F

How can I generate an expression string tag that is the concat of these characters so that the result would be "50GF
" ?

I tried chr() function (cancat(chr({[.]TEST_BYTE_1}), chr({[.]TEST_BYTE_2}), chr({[.]TEST_BYTE_3}), chr({[.]TEST_BYTE_4}))
) but it doesn’t work in the expression panel of my expression tag

Can you help me?

There is no chr() function within Ignition’s expression language. You could add a shared script like this:

def from_ascii(*args):
	buf = []
	for arg in args:
		buf.append(chr(arg))
	return ''.join(buf)

Then call it in your expression tag:
runScript("shared.decode.from_ascii", 0, {[.]TEST_BYTE_1}, {[.]TEST_BYTE_2}, {[.]TEST_BYTE_3}, {[.]TEST_BYTE_4})

2 Likes