Gateway Tag Change scripts issue

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??

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.

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

Best,

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?

Hi roshanbhosale,

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

Thanks,

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.

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.