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):