Struggling to make a script work

I have a script that is works fine until I add an 'and' to the if statement:

def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	system.tag.writeBlocking(['[default]Colder Products Company/Roseville/BurstTester/Start'], [0]),
	
	if currentValue.value > 0 and ('[default]Colder Products Company/Roseville/BurstTester/ProgramNum/MulitpleTestsPrgrm1.value' == 0):
		system.tag.writeBlocking(['[default]BurstTester/Results/UID_of_Desired_Results'], [currentValue.value])	
			

If I comment out everything after the and the program works fine. Is there something wrong with the way I formatted the tag part of the script?

You're comparing a string with an integer. You want to read the tag value and compare with that!

4 Likes

If this is a UDT, you should probably also use relative tag paths.

If I make the tag path not a string, I get this error:

I tried using system.tag.readBlocking and no luck still

	if currentValue.value > 0 and (system.tag.readBlocking('[default]Colder Products Company/Roseville/BurstTester/ProgramNum/MulitpleTestsPrgrm1.value') == 0):
		system.tag.writeBlocking(['[default]BurstTester/Results/UID_of_Desired_Results'], [currentValue.value])	
			```

readBlocking returns an array of qualified values.

You need to do something like this:

if currentValue.value > 0 and (system.tag.readBlocking('[default]Colder Products Company/Roseville/BurstTester/ProgramNum/MulitpleTestsPrgrm1')[0].value == 0):
		system.tag.writeBlocking(['[default]BurstTester/Results/UID_of_Desired_Results'], [currentValue.value])	
			```
2 Likes