# toInt error in tag event script

**URL:** <https://forum.inductiveautomation.com/t/toint-error-in-tag-event-script/14372>\
**Category:** Ignition\
**Created:** [May 22, 2017, 10:32pm UTC](https://forum.inductiveautomation.com/t/toint-error-in-tag-event-script/14372 "2017-05-22T22:32:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael.palmer](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@michael.palmer](https://forum.inductiveautomation.com/u/michael.palmer)\
**Post date:** [May 22, 2017, 10:32pm UTC](https://forum.inductiveautomation.com/t/toint-error-in-tag-event-script/14372/1 "2017-05-22T22:32:07Z")

</div>

I have a tag event, value change script that has a bit of code in it to jump in a sequence. It was working just fine, but then I noticed it was also jumping backward if we had an incomplete step prior in the sequence. To solve this I am trying to do a comparison and its causing some error in trying to compare the stepNum to the number extracted from the column name in the table headers.

```
for col in range(len(headers)):
    work=dta.getValueAt(0, col)
    if col > 0:
        if work != 3:
            gotoStep = col
            head = headers[gotoStep]
            head2 = head[4:]
            headInt = toInt("33.9")
            if headInt > step:
                system.tag.write("[.]jumpToStepNum",head2)
                system.tag.write("[.]jumpToStep",1)
                system.tag.write("[.]doneScan", 0)

```

The script was working error free until I added one line “headInt = toInt(head2)”, which was modified to a fixed number in the Ignition example from the manual. The next line was modified from head2 \> step to “headInt \> step”.

The error is :  
NameError: global name ‘toInt’ is not defined  
INFO | jvm 1 | 2017/05/22 13:18:26 |  
INFO | jvm 1 | 2017/05/22 13:18:26 | at org.python.core.Py.NameError(Py.java:260)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at org.python.core.PyFrame.getglobal(PyFrame.java:265)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at org.python.pycode._pyx3981.valueChanged$1(tagevent:valueChanged:24)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at org.python.pycode.pyx3981.call\_function(tagevent:valueChanged)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at org.python.core.PyTableCode.call(PyTableCode.java:165)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at org.python.core.PyBaseCode.call(PyBaseCode.java:301)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at org.python.core.PyFunction.function\_\_\_call_(PyFunction.java:376)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at org.python.core.PyFunction. **call** (PyFunction.java:371)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at org.python.core.PyFunction. **call** (PyFunction.java:361)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at org.python.core.PyFunction. **call** (PyFunction.java:356)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:663)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at com.inductiveautomation.ignition.common.sqltags.scripts.TagScriptManager$FunctionInvokerImpl.run(TagScriptManager.java:414)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at com.inductiveautomation.ignition.common.sqltags.scripts.AbstractTagScript.invoke(AbstractTagScript.java:34)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at com.inductiveautomation.ignition.common.sqltags.scripts.TagScriptManager$Task.invoke(TagScriptManager.java:353)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at com.inductiveautomation.ignition.common.sqltags.scripts.TagScriptManager$TagScriptDispatcher.run(TagScriptManager.java:318)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at com.inductiveautomation.ignition.common.execution.impl.BasicExecutionEngine$ThrowableCatchingRunnable.run(BasicExecutionEngine.java:546)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at java.util.concurrent.FutureTask.run(Unknown Source)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)  
INFO | jvm 1 | 2017/05/22 13:18:26 | at java.lang.Thread.run(Unknown Source)  
INFO | jvm 1 | 2017/05/22 13:18:26 | Caused by: org.python.core.PyException: Traceback (most recent call last):

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 22, 2017, 10:36pm UTC](https://forum.inductiveautomation.com/t/toint-error-in-tag-event-script/14372/2 "2017-05-22T22:36:16Z")

</div>

`toInt` is a function in the expression language. Try `int(foo)` in python.

---

<div class="post-metadata">

**Author:** ![michael.palmer](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@michael.palmer](https://forum.inductiveautomation.com/u/michael.palmer)\
**Post date:** [May 22, 2017, 10:50pm UTC](https://forum.inductiveautomation.com/t/toint-error-in-tag-event-script/14372/3 "2017-05-22T22:50:32Z")

</div>

doh. Another Bart Simpson moment. Thanks for the assistance. Should have been obvious, but seems most of my script errors are from using the wrong one at the wrong location.
