# Struggling to make a script work

**URL:** <https://forum.inductiveautomation.com/t/struggling-to-make-a-script-work/87494>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [March 18, 2024, 3:28pm UTC](https://forum.inductiveautomation.com/t/struggling-to-make-a-script-work/87494 "2024-03-18T15:28:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Craig](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Ryan\_Craig](https://forum.inductiveautomation.com/u/Ryan_Craig)\
**Post date:** [March 18, 2024, 3:28pm UTC](https://forum.inductiveautomation.com/t/struggling-to-make-a-script-work/87494/1 "2024-03-18T15:28:44Z")

</div>

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

```auto
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?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 18, 2024, 3:39pm UTC](https://forum.inductiveautomation.com/t/struggling-to-make-a-script-work/87494/2 "2024-03-18T15:39:41Z")

</div>

> [@Ryan\_Craig](#):
>
> `... and ('[default]Colder Products ... Prgrm1.value' == 0)`

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

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 18, 2024, 4:07pm UTC](https://forum.inductiveautomation.com/t/struggling-to-make-a-script-work/87494/3 "2024-03-18T16:07:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ryan\_Craig](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Ryan\_Craig](https://forum.inductiveautomation.com/u/Ryan_Craig)\
**Post date:** [March 18, 2024, 4:41pm UTC](https://forum.inductiveautomation.com/t/struggling-to-make-a-script-work/87494/4 "2024-03-18T16:41:05Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/9/790adc9f607d60e53cd678e0f217136db542f49f.png)

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

````auto
	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])	
			```
````

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [March 18, 2024, 4:50pm UTC](https://forum.inductiveautomation.com/t/struggling-to-make-a-script-work/87494/5 "2024-03-18T16:50:58Z")

</div>

readBlocking returns an array of qualified values.

You need to do something like this:

````auto
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])	
			```

````
