V8.1.2 Gateway Timer Script @ 10,000 ms, Fixed delay shared

The script is as below but the tag INT_M1 only returns 0, (or 1 when I reverse the v assignment as the second script). Can anyone explain to me why INT_M1 not returns 0,1,2,…, 10?


//script 1, returns 0

v=system.tag.read("[default]Memory/INT_M1")
if v>10: v=0
else: v=v+1
system.tag.write("[default]Memory/INT_M1", v)


//script 2 returns 1

v=system.tag.read("[default]Memory/INT_M1")
if v<10: v=v+1
else: v=0
system.tag.write("[default]Memory/INT_M1", v)

Take a closer look at the manual. The return from a read is a QV object, wrapping timestamp, value, and quality, not just the actual value. You need to take the .value element of the QV to get your actual tag value.

Thanks pturmel. I re-write the script as below and it works. I have to turn the tag INT_M1’s Deadband mode to off, otherwise the display won’t update its value.


Timer script:
v=system.tag.read("[default]Memory/INT_M1")
if v.value>10: v.value=0
else: v.value = v.value + 1
system.tag.write("[default]Memory/INT_M1", v.value)