# Gateway Tag Change scripts issue

**URL:** <https://forum.inductiveautomation.com/t/gateway-tag-change-scripts-issue/12430>\
**Category:** Ignition\
**Created:** [December 6, 2016, 4:15pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-scripts-issue/12430 "2016-12-06T16:15:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![roshanbhosale](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/roshanbhosale/32/4899_2.png) [@roshanbhosale](https://forum.inductiveautomation.com/u/roshanbhosale)\
**Post date:** [December 6, 2016, 4:15pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-scripts-issue/12430/1 "2016-12-06T16:15:18Z")

</div>

`
cardNumber = newValue.value
for i in range(1,21):
	cardMatch = system.tag.read("[TAS_D]TT/TT%d/nCardNo"%(i)).value
	if cardnumber == cardMatch:
		bayNo = system.tag.read("[TAS_D]TT/TT%d/Comp1/szBayNo"%(i)).value
		if bayNo == 1:
			truckNo = system.tag.read("[TAS_D]TT/TT%d/szTruckNo"%(i)).value
			system.tag.write("[TAS_D]BCDATA/BC1_DATA/TruckNo",truckNo)
			TotalQuantity = system.tag.read("[TAS_D]TT/TT%d/nTotalQuantity"%(i)).value
			system.tag.write("[TAS_D]BCDATA/BC1_DATA/TransactionQuantity",truckNo)
			NoOfComp = system.tag.read("[TAS_D]TT/TT%d/nNoOfComp"%(i)).value
			NoOfComp1 = NoOfComp + 1
			for j in range(1,NoOfComp1):
				batchqty = system.tag.read("[TAS_D]TT/TT%d/Comp%d/fPresetMain"%(i,j)).value
				system.tag.write("[TAS_D]BCDATA/BC1_DATA/Comp%d/BatchQuantity"%(j),batchqty)
		else:
			msg = "Move to bay%s"%(bayNo)
			system.tag.write("[TAS_D]BCDATA/BC1_DATA/Msg1",msg)
	break`

in my project i want to continuously monitor a tag ,once the data gets written into the tag the above script  
should run once and it should pick data from some tags and write it into other tags. but it is not working.

i doubt the syntax used in above code supports in gateway tag Change event script?? is there any other way to achieve it??

another doubt i have is for continuous monitoring of tag should i write this script into gateway timer scripts or gateway tag change script??

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [December 6, 2016, 4:53pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-scripts-issue/12430/2 "2016-12-06T16:53:05Z")

</div>

What’s not working about this? Does it run? Have you tried putting print statements to debug it?

Implementing this as a tag change script on the tag you’re “watching” for change is probably better.

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [December 6, 2016, 5:42pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-scripts-issue/12430/3 "2016-12-06T17:42:25Z")

</div>

Hi there,

You need to learn how to test and debug your Gateway scripts. There are some tips on how to debug Gateway scripts in this article: [perfectabstractions.com/blog … nt-scripts](http://www.perfectabstractions.com/blog/debugging-and-testing-gateway-event-scripts)

Best,

---

<div class="post-metadata">

**Author:** ![roshanbhosale](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/roshanbhosale/32/4899_2.png) [@roshanbhosale](https://forum.inductiveautomation.com/u/roshanbhosale)\
**Post date:** [December 7, 2016, 10:47am UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-scripts-issue/12430/4 "2016-12-07T10:47:41Z")

</div>

Thanks for the reply nmudge and Kevin.Herron the problem got solved…  
one more issue is:  
i am getting debug message continuously in gateway page system console screen .i don’t know where this debug message is coming from and it is logging every 1 second.

some previous test script might be generating this.

how to check where this debug is defined?

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [December 7, 2016, 3:52pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-scripts-issue/12430/5 "2016-12-07T15:52:03Z")

</div>

Hi roshanbhosale,

Can you show a screenshot of the debug messages you are seeing in the Gateway console?

Thanks,

---

<div class="post-metadata">

**Author:** ![roshanbhosale](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/roshanbhosale/32/4899_2.png) [@roshanbhosale](https://forum.inductiveautomation.com/u/roshanbhosale)\
**Post date:** [December 8, 2016, 9:42am UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-scripts-issue/12430/6 "2016-12-08T09:42:00Z")

</div>

this debug is created by me at earlier stage of the project development but i forgot where i defined it and now i am unable to trace it back to its origin.

---

<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:** [December 8, 2016, 2:35pm UTC](https://forum.inductiveautomation.com/t/gateway-tag-change-scripts-issue/12430/7 "2016-12-08T14:35:58Z")

</div>

Export all of your tags, then use an external editor to search the XML file for “This is Debug for”.  
If you don’t find it there, open each project in the designer and use the search & replace feature.
