I am having a problem where, my machine is sending a string value to a tag, but the value only stays momentarily. I am trying to create a memory tag, that would latch this string, so that I can use it even after the original tags value goes away.
Currently I have a tag event script, On Value Change, on the original tag that looks like this:
if "[.]CurrentJob.value" != "":
Where the "CurrentJob" tag is flashing the string value, and the "JobNumberTest_Mem" tag is the one I am trying to latch it to.
This script seems to write to the memory tag fine, but once the string value goes away, it also goes away on the memory tag. Does anyone know of a script I can write to latch the string value on the "JobNumberTest_Mem" tag?
There must be some other script doing that part. Memory tags don't change by themselves.
This works for me.
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
if len(currentValue.value) > 0:
I just created the memory tag and the only thing I have pointing to that tag is that script. I am not sure what else would be affecting the memory tag.
I think your if condition is allowing a None value to pass.
This works the same as my script did..
It will send the value to the other string, but once the value disappears on the CurrentJob tag, it disappears on the memory tag as well..
Actually, you've quoted a tagpath and are expecting it to be a value. It's still a string, and always different from the empty string
If this event is on the
CurrentJob tag, then all you need is this:
First, a tag event gives you the new value in a qualified value variable, then both empty strings and
None evaluate to
False in a conditional context.