# Mismatched input 'tagPathRead' expecting INDENT

**URL:** <https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373>\
**Category:** Ignition\
**Created:** [July 9, 2019, 4:47am UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373 "2019-07-09T04:47:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![tgfgreaves](https://avatars.discourse-cdn.com/v4/letter/t/919ad9/32.png) [@tgfgreaves](https://forum.inductiveautomation.com/u/tgfgreaves)\
**Post date:** [July 9, 2019, 4:47am UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/1 "2019-07-09T04:47:51Z")

</div>

I have created a script which is called when a button is pressed and creates tags dynamically.  
I have included a tag event script in the form of a string.  
I am receiving an error and the tags script does not do what is expected.  
Issue:  
Error compiling event script for event id ‘valueChanged’.  
SyntaxError: (“mismatched input ‘tagPathRead’ expecting INDENT”, (‘tagevent:valueChanged’, 2, 0, ‘tagPathRead = [default]Counts/AU/QLD/1/PM 53/WashCount\n’))

When i go into the tag and press apply the error is removed and the tags script then functions as expected.  
Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![c.bertulli](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@c.bertulli](https://forum.inductiveautomation.com/u/c.bertulli)\
**Post date:** [July 9, 2019, 6:21am UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/2 "2019-07-09T06:21:31Z")

</div>

Can you please post the code also? In this way it will be easier for us to troubleshoot your issue.  
PS: Remember to put the code in Preformatted Text ( Ctrl + Shit + C )

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [July 9, 2019, 1:52pm UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/3 "2019-07-09T13:52:04Z")

</div>

That normally means you did something like

```auto
if condition == value:

othercodeHere

```

and python was expecting some indented code after if/for statement but didn’t see any.

---

<div class="post-metadata">

**Author:** ![jonathan.taylor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jonathan.taylor/32/4048_2.png) [@jonathan.taylor](https://forum.inductiveautomation.com/u/jonathan.taylor)\
**Post date:** [July 9, 2019, 1:54pm UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/4 "2019-07-09T13:54:37Z")

</div>

> PS: Remember to put the code in Preformatted Text ( Ctrl + Shit + C )

I tried that before but I ended up needing new pants 🤣

---

<div class="post-metadata">

**Author:** ![c.bertulli](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@c.bertulli](https://forum.inductiveautomation.com/u/c.bertulli)\
**Post date:** [July 9, 2019, 2:00pm UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/5 "2019-07-09T14:00:58Z")

</div>

AHAHAHAHAH LOL 🤣🤣🤣🤣 missed an f 😅😅

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 9, 2019, 2:26pm UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/6 "2019-07-09T14:26:57Z")

</div>

Actually, don’t use Ctrl-Shift-C for code blocks. Use triple backquotes (these: ```) on a line above and a line below your pasted code.

---

<div class="post-metadata">

**Author:** ![tgfgreaves](https://avatars.discourse-cdn.com/v4/letter/t/919ad9/32.png) [@tgfgreaves](https://forum.inductiveautomation.com/u/tgfgreaves)\
**Post date:** [July 10, 2019, 12:21am UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/7 "2019-07-10T00:21:59Z")

</div>

This is the script i am placing inside the Tag

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/794bbb68d8142c66aef91c26226e0573cfd80b36.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 10, 2019, 12:25am UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/8 "2019-07-10T00:25:12Z")

</div>

You’ve got some mismatched quoting going on in line 1.

---

<div class="post-metadata">

**Author:** ![tgfgreaves](https://avatars.discourse-cdn.com/v4/letter/t/919ad9/32.png) [@tgfgreaves](https://forum.inductiveautomation.com/u/tgfgreaves)\
**Post date:** [July 10, 2019, 12:42am UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/9 "2019-07-10T00:42:45Z")

</div>

How would can i change that first line?

---

<div class="post-metadata">

**Author:** ![tgfgreaves](https://avatars.discourse-cdn.com/v4/letter/t/919ad9/32.png) [@tgfgreaves](https://forum.inductiveautomation.com/u/tgfgreaves)\
**Post date:** [July 10, 2019, 12:54am UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/10 "2019-07-10T00:54:33Z")

</div>

Same issue when i remove the dynamic variable and simplify:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/e/e359c679a1ca4156a8fa8247a56a321888209ec9.png)

---

<div class="post-metadata">

**Author:** ![tgfgreaves](https://avatars.discourse-cdn.com/v4/letter/t/919ad9/32.png) [@tgfgreaves](https://forum.inductiveautomation.com/u/tgfgreaves)\
**Post date:** [July 10, 2019, 12:55am UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/11 "2019-07-10T00:55:14Z")

</div>

I Have this already, see code snippets below.

---

<div class="post-metadata">

**Author:** ![Brian](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Brian](https://forum.inductiveautomation.com/u/Brian)\
**Post date:** [July 10, 2019, 1:43am UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/12 "2019-07-10T01:43:17Z")

</div>

The triple quotes @pturmel was talking about are for posting code to the forum. Copy the text of your script and paste it in between triple quotes in the forum and the forum will format your code nicely. Do this instead of taking a screenshot of your code, it’s easier to read.

In addition to working in the forum, python uses triple quotes to begin and end a block comment. In your most recent screenshot, you have commented out almost all of your script. Right now, the computer is seeing `AutoScript =` and that’s it. Everything in purple is interpreted as a comment. You need to get rid of the triple quotes in your actual code.

---

<div class="post-metadata">

**Author:** ![tgfgreaves](https://avatars.discourse-cdn.com/v4/letter/t/919ad9/32.png) [@tgfgreaves](https://forum.inductiveautomation.com/u/tgfgreaves)\
**Post date:** [July 10, 2019, 1:56am UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/13 "2019-07-10T01:56:33Z")

</div>

I have the triple quotes as i am placing that text inside a tags script.  
So i am using a script to create a tag, which needs the value change script ‘AutoScript’

---

<div class="post-metadata">

**Author:** ![tgfgreaves](https://avatars.discourse-cdn.com/v4/letter/t/919ad9/32.png) [@tgfgreaves](https://forum.inductiveautomation.com/u/tgfgreaves)\
**Post date:** [July 10, 2019, 2:10am UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/14 "2019-07-10T02:10:47Z")

</div>

@Brian  
So the text inside the triple quotes (’’’) is being passed into the a tag to be used for a tags valuechanged event script

---

<div class="post-metadata">

**Author:** ![Brian](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Brian](https://forum.inductiveautomation.com/u/Brian)\
**Post date:** [July 10, 2019, 4:03am UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/15 "2019-07-10T04:03:23Z")

</div>

Oh, ok. I think the rest of us missed that. It’s not readily apparent that that is what you are doing from just looking at the code. I overlooked your description in the original post.

I’m guessing that what’s going on is related to the fact that when you define a tag through the editor and define a tag change script, there’s a little bit of code that ignition generates for you, and the code you write actually ends up indented one level. My guess is that if you are programmatically creating the tag, you need to include the code that ignition usually generates for you, and indent your normal code one level.

I’m guessing what is happening is that when you open the tag editor on one of your programmatically created tags, ignition notices that the code it generates is not there, generates it, and indents everything else in one level. By the time the window draws, it has fixed the problem and all you need to do is apply the changes.

It’s a complete shot in the dark on my end, but I’d start poking around there.

---

<div class="post-metadata">

**Author:** ![tgfgreaves](https://avatars.discourse-cdn.com/v4/letter/t/919ad9/32.png) [@tgfgreaves](https://forum.inductiveautomation.com/u/tgfgreaves)\
**Post date:** [July 10, 2019, 4:11am UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/16 "2019-07-10T04:11:06Z")

</div>

Thanks for the suggestion, but that wasn’t it.

---

<div class="post-metadata">

**Author:** ![tgfgreaves](https://avatars.discourse-cdn.com/v4/letter/t/919ad9/32.png) [@tgfgreaves](https://forum.inductiveautomation.com/u/tgfgreaves)\
**Post date:** [July 10, 2019, 4:13am UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/18 "2019-07-10T04:13:57Z")

</div>

def CreateTags(country, state, depotid, pmid, ewontype):

```
#Tag paths for the tag creation
ftpPath = "[default]FTP/"+str(country)+"/"+str(state)+"/"+str(depotid)+"/PM " + str(pmid)
mqttPath = "[MQTT Engine]"+str(country)+"/"+str(state)+"/"+str(depotid)+"/PM " + str(pmid)

#Tag paths for the Auto Start and Wash Start tags - For the script Counters
autoTagPath = "[default]Counts/PM " + str(pmid) + "/AutoCount"
washTagPath = "[default]Counts/PM " + str(pmid) + "/WashCount"
autoTagPathW = "[default]Counts/PM " + str(pmid)
washTagPathW = autoTagPathW

if ewontype == 0:
	baseTagPath = ftpPath
else:
	baseTagPath = mqttPath
	
#######################################################################################################################################################	
#Auto Count Script
AutoScript = '''tagPathRead = ''' +"'"+ autoTagPath +"'"+'''
tagPathWrite = ''' +"'"+ autoTagPathW +"'"+ '''
count = system.tag.read(tagPathRead).value

tagExist = system.tag.exists(tagPathRead)
if tagExist == False:
	auto = 0
else:
	if currentValue.value == 1:
		auto = count + 1
	else:
		auto = count
# Configure the tags. Manually doing this for the example, but a for-loop could simplify the process.
tagAuto = {
			'name': 'AutoCount',           
			'valueSource': 'memory',
			'value' : auto,
			'tagType' : 'AtomicTag',
			'dataType' : 'Int8'
		}
# Add the tags a list
tagList = [tagAuto]
 
# Set the collision policy. If editing existing tags, then we'll use 'o' to overwrite...
#collisionPolicy = 'o'
#...however, in this example, we'll just abort
collisionPolicy = 'o'
 
# Edit the tags.
system.tag.configure(tagPathWrite, tagList, collisionPolicy)'''

#Create the tag ready for operation
tagAuto = {
			'name': 'AutoCount',           
			'valueSource': 'memory',
			'value' : 0,
			'tagType' : 'AtomicTag',
			'dataType' : 'Int8'
		}
# Add the tags a list
tagList = [tagAuto]
 
# Set the collision policy. If editing existing tags, then we'll use 'o' to overwrite...
#collisionPolicy = 'o'
#...however, in this example, we'll just abort
collisionPolicy = 'o'
 
# Edit the tags.
system.tag.configure(autoTagPathW, tagList, collisionPolicy)

#######################################################################################################################################################
#Wash Count Script
WashScript = '''tagPathRead = ''' +"'"+ washTagPath +"'"+'''
tagPathWrite = ''' +"'"+ washTagPathW +"'"+ '''
count = system.tag.read(tagPathRead).value

tagExist = system.tag.exists(tagPathRead)
if tagExist == False:
	auto = 0
else:
	if currentValue.value == 1:
		auto = count + 1
	else:
		auto = count
# Configure the tags. Manually doing this for the example, but a for-loop could simplify the process.
tagWash = {
			'name': 'WashCount',           
			'valueSource': 'memory',
			'value' : auto,
			'tagType' : 'AtomicTag',
			'dataType' : 'Int8'
		}
# Add the tags a list
tagList = [tagWash]
 
# Set the collision policy. If editing existing tags, then we'll use 'o' to overwrite...
#collisionPolicy = 'o'
#...however, in this example, we'll just abort
collisionPolicy = 'o'
 
# Edit the tags.
system.tag.configure(tagPathWrite, tagList, collisionPolicy)'''

#Create the tag ready for operation
tagWash = {
			'name': 'WashCount',           
			'valueSource': 'memory',
			'value' : 0,
			'tagType' : 'AtomicTag',
			'dataType' : 'Int8'
		}
# Add the tags a list
tagList = [tagWash]
 
# Set the collision policy. If editing existing tags, then we'll use 'o' to overwrite...
#collisionPolicy = 'o'
#...however, in this example, we'll just abort
collisionPolicy = 'o'
 
# Edit the tags.
system.tag.configure(washTagPathW, tagList, collisionPolicy)
	
#######################################################################################################################################################

tagNames = [ "AI 0 Fault",
	"AI 1 Fault",
	"Goliath Comms Fault",
	"Goliath Drive Fault",
	"Goliath Lifter Hyd OL",
	"Goliath Pump OL",
	"Goliath Pump Overheat",
	"Goliath Sheer Pin Jam",
	"Grinder Drive Fault",
	"Lid Has Not Closed",
	"Lid Open Fault",
	"Overfill Alarm",
	"Pulpmaster Sheer Pin Jam",
	"Pump Outfeed Blocked",
	"Pump Overload",
	"Safety Relay Fault",
	"Tank Full",
	"Tank is Full",
	"Tank Three Qrt",
	"Water Pressure Low",
	"Tank 5 percent",
	"Tank Percentage",
	"HMI Reset",
	"Screw Speed",
	"Grinder Run Time"]
	
tagList = []

for tagName in tagNames:
	tag = { "name":tagName,"valueSource": "memory", "value" : 0}
	tagList.append(tag)
        
# Set the collision policy. If editing existing tags, then we'll use "o" to overwrite
collisionPolicy = "o"
 
# Edit the tags.
system.tag.configure(baseTagPath, tagList, collisionPolicy)

#Create the tag for Auto Start which has the script for the Auto Counter
tagList2 = []
tag2 = { "name":"Auto Start","valueSource": "memory", "value" : 0, "eventScripts":{"eventid":"valueChanged", "script":AutoScript}}
tagList2.append(tag2)
# Edit the tags.
system.tag.configure(baseTagPath, tagList2, collisionPolicy)

#Create the tag for Wash Start which has the script for the Wash Counter
tagList3 = []
tag3 = { "name":"Wash Start","valueSource": "memory", "value" : 0, "eventScripts":{"eventid":"valueChanged", "script":WashScript}}
tagList3.append(tag3)
# Edit the tags.
system.tag.configure(baseTagPath, tagList3, collisionPolicy)
	
	

for tagName in tagNames:
	if tagName == tagNames[16]: 
		system.tag.editAlarmConfig([baseTagPath+"/"+tagName],{"":[["name","Value",tagName],["enabled","Value","1"],["priority","Value","High"],["label","Value",tagName],["mode","Value","10"],["activeCondition","Expression","{Value}=True"],["displayPath","Value","PM "+str(pmid)+" Tank"]]})
	elif tagName == tagNames[17]: 
		system.tag.editAlarmConfig([baseTagPath+"/"+tagName],{"":[["name","Value",tagName],["enabled","Value","1"],["priority","Value","High"],["label","Value",tagName],["mode","Value","10"],["activeCondition","Expression","{Value}=True"],["displayPath","Value","PM "+str(pmid)+" Tank"]]})	
	elif tagName == tagNames[18]: 
		system.tag.editAlarmConfig([baseTagPath+"/"+tagName],{"":[["name","Value",tagName],["enabled","Value","1"],["priority","Value","High"],["label","Value",tagName],["mode","Value","10"],["activeCondition","Expression","{Value}=True"],["displayPath","Value","PM "+str(pmid)+" Tank"]]})	
	elif tagName == tagNames[20]: 
		system.tag.editAlarmConfig([baseTagPath+"/"+tagName],{"":[["name","Value",tagName],["enabled","Value","1"],["priority","Value","High"],["label","Value",tagName],["mode","Value","10"],["activeCondition","Expression","{Value}=True"],["displayPath","Value","PM "+str(pmid)+" Tank"]]})	
	else:	
		system.tag.editAlarmConfig([baseTagPath+"/"+tagName],{"":[["name","Value",tagName],["enabled","Value","1"],["priority","Value","High"],["label","Value",tagName],["mode","Value","10"],["activeCondition","Expression","{Value}=True"],["displayPath","Value","PM "+str(pmid)+" Fault"]]})	
			
system.tag.editTag(tagPath = baseTagPath+"/Tank Percentage", attributes={"HistoryEnabled":True})#, "PrimaryHistoryProvider":"Pulp_Master"})
```

---

<div class="post-metadata">

**Author:** ![Brian](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Brian](https://forum.inductiveautomation.com/u/Brian)\
**Post date:** [July 10, 2019, 4:21am UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/19 "2019-07-10T04:21:58Z")

</div>

I was looking around for more information, and I came across [this post.](http://forum.inductiveautomation.com/t/tagevent-script-in-system-tag-addtag/18055/2) If you notice, in the line where Kyle is defining the tag event script, he has a \n just before the print statement. This is putting a tab character at the beginning of the script. And, this is apparently a working configuration. I’m guessing you are missing the tab character, and that’s what ignition is complaining about.

---

<div class="post-metadata">

**Author:** ![Brian](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Brian](https://forum.inductiveautomation.com/u/Brian)\
**Post date:** [July 10, 2019, 4:23am UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/20 "2019-07-10T04:23:22Z")

</div>

You might try moving to a new line immediately after your triple quotes and indenting everything in one level.

---

<div class="post-metadata">

**Author:** ![tgfgreaves](https://avatars.discourse-cdn.com/v4/letter/t/919ad9/32.png) [@tgfgreaves](https://forum.inductiveautomation.com/u/tgfgreaves)\
**Post date:** [July 10, 2019, 5:07am UTC](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373/21 "2019-07-10T05:07:57Z")

</div>

Thanks Brian  
‘\t’ just after the triple quotes (’’’) solved the problem  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/b/b06eb1417f5c5ba5524f2cca0aaddebe1f5e186c.png)

[Next page](https://forum.inductiveautomation.com/t/mismatched-input-tagpathread-expecting-indent/26373.md?page=2)
