# Syntax error on text expression

**URL:** <https://forum.inductiveautomation.com/t/syntax-error-on-text-expression/48917>\
**Category:** Ignition\
**Created:** [July 16, 2021, 7:44pm UTC](https://forum.inductiveautomation.com/t/syntax-error-on-text-expression/48917 "2021-07-16T19:44:35Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![joelle.rennick](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@joelle.rennick](https://forum.inductiveautomation.com/u/joelle.rennick)\
**Post date:** [July 16, 2021, 7:44pm UTC](https://forum.inductiveautomation.com/t/syntax-error-on-text-expression/48917/1 "2021-07-16T19:44:35Z")

</div>

Hello! I am trying to get a text to change what it says based on if 2 tags are true or false. For example, if the RDY (ready) tag is on and the RNG (running) tag is on, the text should say ‘RUNNING’. I have a tag path property on the popup window (in vision) and want this to work indirectly so that the expression on the text will find the RDY and RNG tag of any tag path given. I have tried a few different chunks of code and I can’t get around some errors. If anyone has any advice, it would be greatly appreciated. Here are the two pieces of code I have been experimenting with:

```auto
ready = system.tag.writeToTag((event.source.parent.TagPath)+"/RDY", value)
running = system.tag.writeToTag((event.source.parent.TagPath)+"/RNG", value)
if (ready=1 && running=1, "RUNNING",
if (ready=1 && running=0, "READY",
if (ready=0, "NOT READY")))

```

and…

```auto
if ({[default]Root Container.TagPath/RDY}=1 && {[default]Root Container.TagPath/RNG}=1, "RUNNING",
if ({[default]Root Container.TagPath/RDY}=1 && {[default]Root Container.TagPath/RNG}=0, "READY",
if ({[default]Root Container.TagPath/RDY}=0, "NOT READY")))

```

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [July 16, 2021, 7:52pm UTC](https://forum.inductiveautomation.com/t/syntax-error-on-text-expression/48917/2 "2021-07-16T19:52:31Z")

</div>

Try this for the expression

```auto
if ({default]Root Container.TagPath/RDY} && {[default]Root Container.TagPath/RNG}, "RUNNING",
if ({[default]Root Container.TagPath/RDY} && !{[default]Root Container.TagPath/RNG}, "READY",
"NOT READY"))

```

Your expression doesn’t work because you don’t have a default value (else) for the last if statement you had, but you don’t need the 3rd `if`

---

<div class="post-metadata">

**Author:** ![joelle.rennick](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@joelle.rennick](https://forum.inductiveautomation.com/u/joelle.rennick)\
**Post date:** [July 16, 2021, 7:55pm UTC](https://forum.inductiveautomation.com/t/syntax-error-on-text-expression/48917/3 "2021-07-16T19:55:10Z")

</div>

Thanks for this! When I try this I get an error that says “Invalid tag path: ‘[default]Root Container.TagPath/RDY’. Token PATH\_SEPARATOR found after property name.”

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [July 16, 2021, 7:57pm UTC](https://forum.inductiveautomation.com/t/syntax-error-on-text-expression/48917/4 "2021-07-16T19:57:50Z")

</div>

Delete out the tag paths from the expression, then re-insert them by using the tag browser on the right side of the expression window.

It looks like you are mixing up the scripting language and the expression language.

EDIT:  
Oh I see, you want indirect tag paths. Check out the `tag` expression [tag - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)](https://docs.inductiveautomation.com/display/DOC81/tag)

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [July 16, 2021, 8:09pm UTC](https://forum.inductiveautomation.com/t/syntax-error-on-text-expression/48917/5 "2021-07-16T20:09:27Z")

</div>

You can also create custom properties bound to an indirect address. Then use those properties in your expression.

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [July 16, 2021, 10:18pm UTC](https://forum.inductiveautomation.com/t/syntax-error-on-text-expression/48917/6 "2021-07-16T22:18:56Z")

</div>

```auto
if (tag("sometagpath"+"/RDY")=1 && tag("sometagpath"+"/RNG")=1, "RUNNING",
if (tag("sometagpath"+"/RDY")=1 && tag("sometagpath"+"/RNG")=0, "READY",
if (tag("sometagpath"+"/RNG")=0, "NOT READY")))
```

---

<div class="post-metadata">

**Author:** ![joelle.rennick](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@joelle.rennick](https://forum.inductiveautomation.com/u/joelle.rennick)\
**Post date:** [July 19, 2021, 2:18pm UTC](https://forum.inductiveautomation.com/t/syntax-error-on-text-expression/48917/7 "2021-07-19T14:18:09Z")

</div>

This seems to solve some of my problems but when I use the code below, I get this error:  
“Syntax Error on Token: ‘COMMA’ (Line 1 , Char 86)”  
I’ve tried a few different variations and can’t get them to work. Do you know what I am doing wrong? Thank you!!

```auto
if (tag("Root Container.TagPath"+"/RDY")=1 && tag("Root Container.TagPath"+"/RNG")=1, "RUNNING",
if (tag("Root Container.TagPath"+"/RDY")=1 && tag("Root Container.TagPath"+"/RNG")=0, "READY",
if (tag("Root Container.TagPath"+"/RDY")=0, "NOT READY")))

```

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [July 19, 2021, 2:21pm UTC](https://forum.inductiveautomation.com/t/syntax-error-on-text-expression/48917/8 "2021-07-19T14:21:05Z")

</div>

> [@joelle.rennick](#):
>
> `&& (tag(`

hm nvm idk what you are trying here xd

---

<div class="post-metadata">

**Author:** ![joelle.rennick](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@joelle.rennick](https://forum.inductiveautomation.com/u/joelle.rennick)\
**Post date:** [July 19, 2021, 2:26pm UTC](https://forum.inductiveautomation.com/t/syntax-error-on-text-expression/48917/9 "2021-07-19T14:26:21Z")

</div>

Yes, thanks I’ve fixed that now. Unfortunately, I am still getting the COMMA error.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [July 19, 2021, 2:29pm UTC](https://forum.inductiveautomation.com/t/syntax-error-on-text-expression/48917/10 "2021-07-19T14:29:32Z")

</div>

> [@joelle.rennick](#):
>
> `if (tag("Root Container.TagPath"+"/RDY")=0, "NOT READY")))`

you are missing a second value here if the if is false somehting like this? `if(tag("Root Container.TagPath"+"/RDY")=0, "NOT READY","NOT READY?")`

this does not give me parsing errors:  
`if (tag("Root Container.TagPath"+"/RDY")=1 && tag("Root Container.TagPath"+"/RNG")=1, "RUNNING", if(tag("Root Container.TagPath"+"/RDY")=1 && tag("Root Container.TagPath"+"/RNG")=0, "READY",if(tag("Root Container.TagPath"+"/RDY")=0, "NOT READY","NOT READY?")))`

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [July 19, 2021, 2:32pm UTC](https://forum.inductiveautomation.com/t/syntax-error-on-text-expression/48917/11 "2021-07-19T14:32:38Z")

</div>

I’ve discovered a new way to look at these situations with `case` instead of nested `ifs`, thanks to @mcgheeiv.

```auto
case(True
    , tag("Root Container.TagPath"+"/RDY") && tag("Root Container.TagPath"+"/RNG"), "RUNNING"
    , tag("Root Container.TagPath"+"/RDY") && !tag("Root Container.TagPath"+"/RNG"), "READY"
    , !tag("Root Container.TagPath"+"/RDY"), "NOT READY"
    , "NOT READY")

```
