# 'Error expanding parameter reference' in Tag Event script when using curly braces

**URL:** <https://forum.inductiveautomation.com/t/error-expanding-parameter-reference-in-tag-event-script-when-using-curly-braces/41047>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [November 30, 2020, 2:59pm UTC](https://forum.inductiveautomation.com/t/error-expanding-parameter-reference-in-tag-event-script-when-using-curly-braces/41047 "2020-11-30T14:59:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![chi](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@chi](https://forum.inductiveautomation.com/u/chi)\
**Post date:** [November 30, 2020, 2:59pm UTC](https://forum.inductiveautomation.com/t/error-expanding-parameter-reference-in-tag-event-script-when-using-curly-braces/41047/1 "2020-11-30T14:59:54Z")

</div>

Using pythons string.format placeholders in a tag event scripts collides with Ignitions parameter references in 8.1.0. There are workarounds, but i spent some time before i found the cause of the script error. Maybe there should be a warning in the manual about using curly braces in tag event scripts.

I never realized that parameters in curly braces are supported in tag event scripts. Is this a new feature in 8.1?

The script

```auto
test='{0} {1}'.format(tag, tagPath)

```

shows the error

```auto
Error expanding parameter reference
java.lang.NullPointerException

```

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 2, 2020, 11:53am UTC](https://forum.inductiveautomation.com/t/error-expanding-parameter-reference-in-tag-event-script-when-using-curly-braces/41047/2 "2020-12-02T11:53:59Z")

</div>

~~`You're using Python 3 syntax, whereas Ignition uses Jython 2.7 which doesn't support the `format`function. You need to use the 2.7 method, e.g.:`test=’%s %s’ %(tag, tagPath)`~~  
I stand corrected… I thought this was added in 3, but turns out it was 2.7  
In any case, you can use the old method to work around the issue

---

<div class="post-metadata">

**Author:** ![chi](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@chi](https://forum.inductiveautomation.com/u/chi)\
**Post date:** [December 2, 2020, 12:39pm UTC](https://forum.inductiveautomation.com/t/error-expanding-parameter-reference-in-tag-event-script-when-using-curly-braces/41047/3 "2020-12-02T12:39:53Z")

</div>

There is still the problem that curly braces are also used for dictionaries in python `{'init1': 1, 'init2': 2}`.  
Maybe not commonly used in tag event scripts, but imho parameter replacement in script sourcecode is not a good idea, especially when it is not documented.

---

<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:** [December 2, 2020, 4:14pm UTC](https://forum.inductiveautomation.com/t/error-expanding-parameter-reference-in-tag-event-script-when-using-curly-braces/41047/4 "2020-12-02T16:14:08Z")

</div>

If I remember the timeline correctly, automatic parameter expansion was a “feature” in 7.9 and previous, then deliberately omitted in early 8.0.X versions in favor of an explicit syntax…then added back in after backwards compatibility complaints.

There’s no winning, here.

---

<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:** [December 2, 2020, 4:24pm UTC](https://forum.inductiveautomation.com/t/error-expanding-parameter-reference-in-tag-event-script-when-using-curly-braces/41047/5 "2020-12-02T16:24:55Z")

</div>

The best way to avoid this particular issue is to move the code into a script module and delegate from the tag event.

---

<div class="post-metadata">

**Author:** ![chi](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@chi](https://forum.inductiveautomation.com/u/chi)\
**Post date:** [December 2, 2020, 5:39pm UTC](https://forum.inductiveautomation.com/t/error-expanding-parameter-reference-in-tag-event-script-when-using-curly-braces/41047/6 "2020-12-02T17:39:36Z")

</div>

Since parameters are dynamic in 8.x, does that mean the script runs through parameter replacement and is recompiled on every single invocation and seperately for every UDT instance?

---

<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:** [December 2, 2020, 7:09pm UTC](https://forum.inductiveautomation.com/t/error-expanding-parameter-reference-in-tag-event-script-when-using-curly-braces/41047/7 "2020-12-02T19:09:32Z")

</div>

Not a clue 🙂 - @ggross may know?

---

<div class="post-metadata">

**Author:** ![chi](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@chi](https://forum.inductiveautomation.com/u/chi)\
**Post date:** [December 3, 2020, 11:47am UTC](https://forum.inductiveautomation.com/t/error-expanding-parameter-reference-in-tag-event-script-when-using-curly-braces/41047/8 "2020-12-03T11:47:04Z")

</div>

I totally missed the documentation for the legacy curly bracket approach, so please ignore my complaints about missing docs. That info also answers my above question.

> A large caveat with this approach is that value changes made to the parameter ("myParam", in the example above) would not be reflected in scripts until the UDT was restarted. UDT parameters are pre-compiled, which in this case means value changes are mostly ignored until the UDT is restarted.
