# Problem with scripting Tag editor

**URL:** <https://forum.inductiveautomation.com/t/problem-with-scripting-tag-editor/105070>\
**Category:** Ignition\
**Created:** [April 14, 2025, 5:37pm UTC](https://forum.inductiveautomation.com/t/problem-with-scripting-tag-editor/105070 "2025-04-14T17:37:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![medaminemhadhbi](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@medaminemhadhbi](https://forum.inductiveautomation.com/u/medaminemhadhbi)\
**Post date:** [April 14, 2025, 5:37pm UTC](https://forum.inductiveautomation.com/t/problem-with-scripting-tag-editor/105070/1 "2025-04-14T17:37:03Z")

</div>

Hello,  
So i'm trying to increment a numeric value , for each time a tag switches from 1 -\> 0 , i should increment my numeric value. I tried this in scripting withing the tag editor but nothing changes in my numeric value

```python
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	if not initialChange:
	# Détection d’un front descendant : passage de 1 à 0 (arrêt du convoyeur)
		if previousValue.value == 1 and currentValue.value == 0:
		# Lire la valeur actuelle du compteur
			compteur = system.tag.readBlocking(["[default]Valeur"])[0].value
		# Incrémenter le compteur
			system.tag.writeBlocking(["[default]Valeur"], [compteur + 1])

```

---

<div class="post-metadata">

**Author:** ![Kevin\_Flener](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kevin\_Flener](https://forum.inductiveautomation.com/u/Kevin_Flener)\
**Post date:** [April 14, 2025, 7:06pm UTC](https://forum.inductiveautomation.com/t/problem-with-scripting-tag-editor/105070/2 "2025-04-14T19:06:03Z")

</div>

I think you should perform the math before the writeBlocking call, and just use the variable in the call. Something like:

```python

def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	if not initialChange:
	# Détection d’un front descendant : passage de 1 à 0 (arrêt du convoyeur)
		if previousValue.value == 1 and currentValue.value == 0:
		# Lire la valeur actuelle du compteur
			compteur = system.tag.readBlocking(["[default]Valeur"])[0].value + 1
		# Incrémenter le compteur
			system.tag.writeBlocking(["[default]Valeur"], compteur)

```

Or maybe a separate line after you get the initial value for compteur like

```python
...
compteur = system.tag.readBlocking(["[default]Valeur"])[0].value
compteur = compteur + 1
...

```
