Hello All:
I’ve written a script for a tag whenever there is a value change. I am trying to print new value on the console, but it is not working. Please check the code below and let me know if I am doing anything wrong
print “New Value for %s: %s:” %(tagPath,currentValue)
Thanks,
Shwetha.
Define console? What scope? Gateway or Client/Designer. If you are looking for a more reliable way to log thins, use system.util.getLogger()
Also, as a side note,have you had a chance to complete Inductive University yet? I believe this is answered there.
Hi @shwethag,
Tag event scripts cannot print into the console. Instead, you have to print in the log of the Gateway:
logger = system.util.getLogger("myLogger")
logger.info("New Value for %s: %s:" %(tagPath,currentValue.value))
Note that currentValue is a "qualified value", so you need to specify you want to get the value as I did in the example above
Thanks Kyle:
I was referring the user manual. The code I mentioned in the question is a copy from the example given in the user manual for “value change event” for a tag.
Yeah, the would log to the gateway. You need to use system.util.getLogger().
Thank you.
I'll try this. I followed the example given in the user manual. I wonder why is it mentioned in the manual if is not possible to print it on the console.
Where are you looking at? This is the example I see in the user manual:
This script will fetch all of the possible parameters in the tag changed script.
Note that this will not print out to the console, but it will print to the wrapper logs located on the gateway.
path = tagPath
prev = previousValue
cur = currentValue
init = initialChange
missed = missedEvents
print path, prev.value, cur.quality, init, missed
Read carefully the second comment (Note that this will not print out to the console, but it will print to the wrapper logs located on the gateway.)
Yeap. This can be confusing for new users. Actually it says Because these events are on Tags, they are Gateway Scoped. so the example in the screenshot is the worst one they could chose I guess ![:stuck_out_tongue: :stuck_out_tongue:](http://forum.inductiveautomation.com/images/emoji/twitter/stuck_out_tongue.png?v=6)
Aww… could you please let me know where to look in detail. There is so much info. I get lost sometimes.
Thanks,
Shwetha.
Just go to your Gateway > Status and in the left panel, you will find Logs below Diagnostics