Expression incrementing

if (substring({[.]Scan}, 0, 1) =‘N’, {[.]ScannerNoReads}+1, {[.]ScannerNoReads}+0)
Should increment my tag…
The problem I see with this is that while my condition is true, this keeps firing.
I would like to see this work only once each time the tag changes…One of the problems with using a tag change script however, was that I also may have 2 identical tags that need to be read as 2 different events.

Expression tags run at a scan class rate just like OPC tags which explains why it runs multiple times. The best scenario will be either a transaction group or a tag change script. With a tag change script you can have a single script that runs for multiple tags. You don’t have to create multiple tag change scripts for each tag you want to listen for.

I went down this path and had a similar problem. I found that including a comparison of the LastChange timestamps of the two tags involved did the trick. For what it’s worth, this was my final expression:

forceQuality(if({[~]TestCounter}=null,0,if([color=#0000BF]({[~]TestSignal}=1) && ({[~]TestCounter.LastChange}<{[~]TestSignal.LastChange})[/color],{[~]TestCounter}+1,{[~]TestCounter})))

I was working with memory tags and found that I needed to enclose the expression within the “forceQuality” function to prevent the quality of resultant expression tag from being “Unknown”. All that being said, this probably isn’t the right approach because you could miss a count if if the clock on the Gateway system is adjusted to an earlier time.