# Indirect tag string?

**URL:** <https://forum.inductiveautomation.com/t/indirect-tag-string/4774>\
**Category:** Ignition\
**Created:** [July 5, 2012, 6:36pm UTC](https://forum.inductiveautomation.com/t/indirect-tag-string/4774 "2012-07-05T18:36:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cja7928](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@cja7928](https://forum.inductiveautomation.com/u/cja7928)\
**Post date:** [July 5, 2012, 6:36pm UTC](https://forum.inductiveautomation.com/t/indirect-tag-string/4774/1 "2012-07-05T18:36:08Z")

</div>

how would I write a value to a tag where the tag name changes depending on a variable?

example:

I have a bunch of tags - ‘PN001’ through ‘PN100’

and I have a variable that defines what the number portion of the tag is, so i want to add “PN” to my variable and then use this value as the tag… something like this:

value = 500  
x = PN  
variable = 001  
tag = str(x + variable)  
system.tag.writeToTag(tag, value)

thank you.

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [July 5, 2012, 6:54pm UTC](https://forum.inductiveautomation.com/t/indirect-tag-string/4774/2 "2012-07-05T18:54:06Z")

</div>

Since the “tag” variable that is passed via system.tag.writeToTag needs to be a string, you have to make sure the value inside that variable is indeed a string. You can do this with either string concatenation or string substitution, concatenation should be more efficient however. Putting the values for the variables in quotes, and using the concat operator (+) will do the trick:

value = 500  
x = “PN”  
variable = “001”  
tag = x + variable  
system.tag.writeToTag(tag, value)

---

<div class="post-metadata">

**Author:** ![cja7928](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@cja7928](https://forum.inductiveautomation.com/u/cja7928)\
**Post date:** [July 5, 2012, 8:42pm UTC](https://forum.inductiveautomation.com/t/indirect-tag-string/4774/3 "2012-07-05T20:42:22Z")

</div>

thank you, thats what I was missing. 😃
