# Not able to execute script in Tag

**URL:** <https://forum.inductiveautomation.com/t/not-able-to-execute-script-in-tag/20810>\
**Category:** Ignition\
**Created:** [November 13, 2018, 6:40pm UTC](https://forum.inductiveautomation.com/t/not-able-to-execute-script-in-tag/20810 "2018-11-13T18:40:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [November 13, 2018, 6:40pm UTC](https://forum.inductiveautomation.com/t/not-able-to-execute-script-in-tag/20810/1 "2018-11-13T18:40:26Z")

</div>

I have the Tag script as below,

```auto
def valueChanged (tagPath, previousValue, currentValue, initialChange, missedEvents):

    if not "[.]IsSeries2000":
		if currentValue.value != previousValue.value:
			index = tagPath.find('RawRead')
			tagDir = tagPath[0:index]
			value = currentValue.value
			print "Yeah"
			processMessage(value, tagDir)

def processMessage(value, tagDir):
	import traceback
		
	TestType = system.tag.read("%s/TestType" % (tagDir)).value
	statusMessage = TestType + ': Not set'
	startRequired = 0

	if TestType == 'MDR':
		system.tag.write("[.]TestEnded", 1)
		statusMessage = 'End of MDR test processed.'
		indexRootDir = tagDir.find('Machine/')
		rootDir = tagDir[0:indexRootDir]

	for row in value:
		if row[0] == "ML":
			system.tag.write("%s/MLS1", row[1])
			
	return None

```

Where the value of the tag is,

```auto
Name Value
Test Time 3.0
Test Temp 145.0
Torque Range 8.0
I-Filter 6.0
ML 2.24
MH 5.8
TS2 dNm 0.63
T10 0.38
T50 0.59
T90 0.94
Max Rate 7.05
TS1 dNm 0.48
tanD@MH 0.308
tanD@ML 0.571
T25 0.46
T30 0.49
crazy result 10.27
T40 0.54
T60 0.66
TC90-TC10 0.57

```

Basically, I m trying to pull the particular value from this but it’s not doing anything.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [November 13, 2018, 7:10pm UTC](https://forum.inductiveautomation.com/t/not-able-to-execute-script-in-tag/20810/2 "2018-11-13T19:10:32Z")

</div>

What are you looking for that would tell you that the code isn’t doing anything? I assume you’re looking for a change in the MSL1 tag that you are writing to.

So long as there is no error in the script which you can find by looking in the tag diagnostics, my best guess is that currentValue.value is not returning what you think it is.

What is the type of this tag? I’m assuming that it is a string, but it could also be a dataset.

If it is a string data type then your for loop would be looping through each character in the string, as such your if statement will never be true and you will never write to the tag.

You may want to look into the split function, but I think we need a little more information to properly help with your issue.

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [November 13, 2018, 7:13pm UTC](https://forum.inductiveautomation.com/t/not-able-to-execute-script-in-tag/20810/3 "2018-11-13T19:13:03Z")

</div>

It is a dataset and if i hit the tag outside the UDT, it will work. But the method described below is not working,

```auto
index = tagPath.find('RawRead')
			tagDir = tagPath[0:index]

```

even I have the tag name RawRead.

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [November 13, 2018, 7:18pm UTC](https://forum.inductiveautomation.com/t/not-able-to-execute-script-in-tag/20810/4 "2018-11-13T19:18:15Z")

</div>

Worked. May be a syntax or Formatting Error.

Thanks.
