Not able to write to boolean tag

I am having trouble finding the error in this code:

def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	if currentValue == 3:
		system.tag.writeBlocking("[.]MultipleTestsPrgrm.value",1)
	else:
		system.tag.writeBlocking("[.]MultipleTestsPrgrm.value",0)

I am simply trying to flip a boolean tag to true when the currentValue of the tag changes to a 3, and flip the boolean tag to false on any other number.

Any ideas?

Looks like you need your tag path to be a list, even if one tag.

  1. writeBlocking is expecting two lists.
    system.tag.writeBlocking(["[.]MultipleTestsPrgrm.value]", [1])
    It may work for now when there is only one of each but it could break on a future upgrade.
  2. Where is "[.]" pointing to? Have you got Project | General | Tag Settings | Default Provider set properly? Try changing [.] to [default] or whatever your default provider name is.

currentValue is a complex, qualified value object. You need to pull out just the value property:
if currentValue.value == 3:

1 Like

I added the to make it a list, and changed the [.] to the full tag path and it seems to work now. The [.] before the tag was added when I used the 'insert tag' button next to the scripting area. I just manually added the full tag path and it seem to fix it.
Thanks!