I’m trying to add some error checking to a functioning script. The only thing new is the IF statement, which is throwing the following error:
ERROR [ComponentScriptEditor-AWT-EventQueue-0] Parse error for event handler “actionPerformed”
SyntaxError: (“mismatched input ‘SerialNo’ expecting NEWLINE”, (’’, 22, 3, ‘If SerialNo != 0:\n’))
Code is shown below. Any suggestions would be appreciated. Using Ignition 7.6.4.
Chris
YPartNo = system.tag.read(“AnvilInstall/YPartNo”).value
SerialNo = system.tag.read(“AnvilInstall/SerialNo”).value
CycleCount = system.db.runPrepQuery(“SELECT RunCount FROM PressEvent WHERE ID = ?”, [event.source.parent.PressEventID])
CycleCount = CycleCount[0][0]
#Add a record to the Anvil table
pk = system.db.runUpdateQuery(“INSERT INTO Anvil (YPartNo, SerialNo) VALUES (’%s’, %d)” % (YPartNo, SerialNo),getKey = 1)
system.tag.write(“AnvilInstall/AnvilID”, pk)
Add a record to the AnvilInstall table.
PressEventID = event.source.parent.PressEventID
Position = event.source.parent.Position
If SerialNo != 0:
system.db.runUpdateQuery(“INSERT INTO AnvilInstall (PressEventID, AnvilID, Position, PressCycles) VALUES (%d,%d,%d,%d)” % (PressEventID, pk, Position, CycleCount))
#Update the AnvilID to its new value in the AnvilLoc table of the anvil being.
system.db.runPrepUpdate(“UPDATE AnvilLoc SET AnvilID = ? Where Press = ? AND Position = ?”, [pk, event.source.parent.PressNo, event.source.parent.Position])
# Clear values before next AnvilInstall data entered
system.tag.write(“AnvilInstall/SerialNo”, “0”)
# Close AnvilInstall window
system.nav.closeParentWindow(event)
Else:
event.source.parent.getComponent(‘Label Error SerialNo’).visible = 1