# Convert Ascii value in tag to String

**URL:** <https://forum.inductiveautomation.com/t/convert-ascii-value-in-tag-to-string/44490>\
**Category:** Ignition\
**Created:** [March 15, 2021, 6:06pm UTC](https://forum.inductiveautomation.com/t/convert-ascii-value-in-tag-to-string/44490 "2021-03-15T18:06:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![hydradenlon](https://avatars.discourse-cdn.com/v4/letter/h/c37758/32.png) [@hydradenlon](https://forum.inductiveautomation.com/u/hydradenlon)\
**Post date:** [March 15, 2021, 6:06pm UTC](https://forum.inductiveautomation.com/t/convert-ascii-value-in-tag-to-string/44490/1 "2021-03-15T18:06:18Z")

</div>

Tag recieving data from input as Ascii (int value)  
but I want to convert Ascii to String to show as a character  
\*for example right now tag value is 65 and I want to convert to “A”

Thank you ,

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [March 15, 2021, 7:37pm UTC](https://forum.inductiveautomation.com/t/convert-ascii-value-in-tag-to-string/44490/2 "2021-03-15T19:37:25Z")

</div>

Where ever you are using the value, in a script you can just use the chr() function to convert the value over to the Ascii character.

```auto
asciiString = chr(system.tag.readBlocking(['yourTagPath'][0].value)

```

---

<div class="post-metadata">

**Author:** ![hydradenlon](https://avatars.discourse-cdn.com/v4/letter/h/c37758/32.png) [@hydradenlon](https://forum.inductiveautomation.com/u/hydradenlon)\
**Post date:** [March 16, 2021, 1:36am UTC](https://forum.inductiveautomation.com/t/convert-ascii-value-in-tag-to-string/44490/3 "2021-03-16T01:36:27Z")

</div>

Where do I put this code in design?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [March 16, 2021, 2:23am UTC](https://forum.inductiveautomation.com/t/convert-ascii-value-in-tag-to-string/44490/4 "2021-03-16T02:23:38Z")

</div>

That depends on what you’re trying to accomplish with it.

---

<div class="post-metadata">

**Author:** ![hydradenlon](https://avatars.discourse-cdn.com/v4/letter/h/c37758/32.png) [@hydradenlon](https://forum.inductiveautomation.com/u/hydradenlon)\
**Post date:** [March 16, 2021, 9:01am UTC](https://forum.inductiveautomation.com/t/convert-ascii-value-in-tag-to-string/44490/5 "2021-03-16T09:01:18Z")

</div>

Traceback (most recent call last):  
File “”, line 2, in   
AttributeError: ‘str’ object has no attribute ‘value’  
change = system .tag.readBlocking(’[default]_Modbus_/UnitId 1/1\_test1-1\_test20’[0].value)  
print str(change)

I put it in Script Console , the result is error  
What’s the problem?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [March 16, 2021, 11:27am UTC](https://forum.inductiveautomation.com/t/convert-ascii-value-in-tag-to-string/44490/6 "2021-03-16T11:27:42Z")

</div>

Your second. `)` is in the wrong place. It should be

```auto
change = system.tag.readBlocking(‘[default]Modbus/UnitId 1/1_test1-1_test20’)[0].value

```

---

<div class="post-metadata">

**Author:** ![hydradenlon](https://avatars.discourse-cdn.com/v4/letter/h/c37758/32.png) [@hydradenlon](https://forum.inductiveautomation.com/u/hydradenlon)\
**Post date:** [March 17, 2021, 4:04am UTC](https://forum.inductiveautomation.com/t/convert-ascii-value-in-tag-to-string/44490/7 "2021-03-17T04:04:09Z")

</div>

I follow your advice ,but the result still error

SyntaxError: ("no viable alternative at input 'print'", ('', 2, 0, 'print code\n'))

And then I try

```auto

tagValue = system.tag.readBlocking('[default]_Modbus_/UnitId 1/1_test1-1_test20/1_test2')[0].value
code = chr(tagValue)
print code

```

The result is error too.  
Java Traceback:  
Traceback (most recent call last):  
File "", line 2, in   
at com.inductiveautomation.ignition.common.TypeUtilities.coerce(TypeUtilities.java:1422)  
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.coerce(PyArgumentMap.java:130)  
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.interpretPyArgs(PyArgumentMap.java:82)  
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.interpretPyArgs(PyArgumentMap.java:40)  
at com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.readBlocking(AbstractTagUtilities.java:361)  
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)  
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)  
at java.base/java.lang.reflect.Method.invoke(Unknown Source)  
java.lang.ClassCastException: java.lang.ClassCastException: Cannot coerce value '[default]_Modbus_/UnitId 1/1\_test1-1\_test20/1\_test2' into type: interface java.util.List

```
at org.python.core.Py.JavaError(Py.java:552)
at org.python.core.Py.JavaError(Py.java:543)
at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:190)
at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction. __call__ (ScriptManager.java:523)
at org.python.core.PyObject. __call__ (PyObject.java:480)
at org.python.core.PyObject. __call__ (PyObject.java:484)
at org.python.pycode._pyx9.f$0(<input>:3)
at org.python.pycode._pyx9.call_function(<input>)
at org.python.core.PyTableCode.call(PyTableCode.java:171)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1614)
at org.python.core.Py.exec(Py.java:1658)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:276)
at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:131)
at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$ConsoleWorker.doInBackground(JythonConsole.java:605)
at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$ConsoleWorker.doInBackground(JythonConsole.java:593)
at java.desktop/javax.swing.SwingWorker$1.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.desktop/javax.swing.SwingWorker.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)

```

Caused by: java.lang.ClassCastException: Cannot coerce value '[default]_Modbus_/UnitId 1/1\_test1-1\_test20/1\_test2' into type: interface java.util.List  
at com.inductiveautomation.ignition.common.TypeUtilities.coerce(TypeUtilities.java:1422)  
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.coerce(PyArgumentMap.java:130)  
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.interpretPyArgs(PyArgumentMap.java:82)  
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.interpretPyArgs(PyArgumentMap.java:40)  
at com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.readBlocking(AbstractTagUtilities.java:361)  
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)  
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)  
at java.base/java.lang.reflect.Method.invoke(Unknown Source)  
at org.python.core.PyReflectedFunction. **call** (PyReflectedFunction.java:188)  
... 19 more  
Traceback (most recent call last):  
File "", line 2, in   
at com.inductiveautomation.ignition.common.TypeUtilities.coerce(TypeUtilities.java:1422)  
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.coerce(PyArgumentMap.java:130)  
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.interpretPyArgs(PyArgumentMap.java:82)  
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.interpretPyArgs(PyArgumentMap.java:40)  
at com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.readBlocking(AbstractTagUtilities.java:361)  
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)  
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)  
at java.base/java.lang.reflect.Method.invoke(Unknown Source)  
java.lang.ClassCastException: java.lang.ClassCastException: Cannot coerce value '[default]_Modbus_/UnitId 1/1\_test1-1\_test20/1\_test2' into type: interface java.util.List

> > >

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [March 17, 2021, 4:56am UTC](https://forum.inductiveautomation.com/t/convert-ascii-value-in-tag-to-string/44490/8 "2021-03-17T04:56:22Z")

</div>

> [@hydradenlon](#):
>
> java.lang.ClassCastException: java.lang.ClassCastException: Cannot coerce value ‘[default] _Modbus_ /UnitId 1/1\_test1-1\_test20/1\_test2’ into type: interface java.util.List

This is giving you an error because `system.tag.readBlocking` needs a list, even if there's only one tag to read. Add square brackets around the tag name as below. Once this bites you enough times, you'll start to remember the first time--or at least that's the way it worked for me 😅

```auto
change = system.tag.readBlocking(['[default]Modbus/UnitId 1/1_test1-1_test20'])[0].value

```

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [March 17, 2021, 5:27am UTC](https://forum.inductiveautomation.com/t/convert-ascii-value-in-tag-to-string/44490/9 "2021-03-17T05:27:48Z")

</div>

> [@witman](#):
>
> Once this bites you enough times, you’ll start to remember the first time–or at least that’s the way it worked for me 😅

🤦‍♂️ Apparently not.

Sorry for the buggy script @hydradenlon
