Converting value in tag ( real - time )

I put this code in Script console and it can convert value in tag to character
But the problem is It isn’t show in tag (display)
What should I do to convert value in tag real-time and show in display.

tagValue = system.tag.read("[default]Modbus/UnitId 1/1_test1-1_test20/1_test2")
character = chr(tagValue.value)
print character

You’ll want to convert Mode to Alphanumeric and bind to Text rather than Value.
image
You could use an expression binding like this on Text to run the script to convert the tag value to an ASCII character:

runScript("chr(" + {[default]Modbus/UnitId 1/1_test1-1_test20/1_test2} + ")", 500)

It may make more sense to do this in a derived tag with this read expression:

runScript("chr(" + {source} + ")", 500)

Then you can bind your display’s Text directly to the derived tag.

It works! Thank you so muchhhh

1 Like