SFC Script Failing

This script keeps failing. Basically what I’m trying to do is subtract the ‘pkQty’ from the ‘bal’ and store it in the ‘Contqty’

[code]<?xml version="1.0" ?>

def onStart(chart, step):
This will run when the step starts, before any
other action.

	chart: A reference to the chart's scope.
	step: A reference to this step's scope.
bal = system.tag.read('[Ladson_SC]PartManagement/balance')
pkQty = system.tag.read('[Ladson_SC]PartManagement/PackQty')

ContQty = system.tag.write('[Ladson_SC]PartManagement/balance', bal-pkQty)
chart.count +=1</start-script>


I don’t use SFC but your tag reads are returning qualified values so that might be the problem.

bal = system.tag.read('[Ladson_SC]PartManagement/balance').value pkQty = system.tag.read('[Ladson_SC]PartManagement/PackQty').value

it’s failing on this:

ContQty = system.tag.write('[Ladson_SC]PartManagement/balance', bal-pkQty)

and I’m assuming it’s because of the “bal-pkQty”

[quote=“jreynolds”]… I’m assuming it’s because of the “bal-pkQty”
Thouhgts?[/quote]Yes, because system.tag.read() is not giving you numbers, it’s giving you objects. You have to use the .value property of those objects as JGJohnson showed to get the numbers to subtract.