# SFC Script Failing

**URL:** <https://forum.inductiveautomation.com/t/sfc-script-failing/11080>\
**Category:** Ignition\
**Created:** [January 20, 2016, 11:18pm UTC](https://forum.inductiveautomation.com/t/sfc-script-failing/11080 "2016-01-20T23:18:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jreynolds](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jreynolds](https://forum.inductiveautomation.com/u/jreynolds)\
**Post date:** [January 20, 2016, 11:18pm UTC](https://forum.inductiveautomation.com/t/sfc-script-failing/11080/1 "2016-01-20T23:18:44Z")

</div>

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.

```
Arguments:
	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>
</step>

```

[/code]

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [January 20, 2016, 11:28pm UTC](https://forum.inductiveautomation.com/t/sfc-script-failing/11080/2 "2016-01-20T23:28:00Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![jreynolds](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jreynolds](https://forum.inductiveautomation.com/u/jreynolds)\
**Post date:** [January 20, 2016, 11:30pm UTC](https://forum.inductiveautomation.com/t/sfc-script-failing/11080/3 "2016-01-20T23:30:01Z")

</div>

it’s failing on this:

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

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

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 21, 2016, 2:46am UTC](https://forum.inductiveautomation.com/t/sfc-script-failing/11080/4 "2016-01-21T02:46:48Z")

</div>

[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.
