# Can't seem to assign value to (new) variable within IF statement, Syntax Error on Token: 'EQUAL'

**URL:** <https://forum.inductiveautomation.com/t/cant-seem-to-assign-value-to-new-variable-within-if-statement-syntax-error-on-token-equal/54697>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [January 5, 2022, 6:02pm UTC](https://forum.inductiveautomation.com/t/cant-seem-to-assign-value-to-new-variable-within-if-statement-syntax-error-on-token-equal/54697 "2022-01-05T18:02:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacob\_Sanchez](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@Jacob\_Sanchez](https://forum.inductiveautomation.com/u/Jacob_Sanchez)\
**Post date:** [January 5, 2022, 6:02pm UTC](https://forum.inductiveautomation.com/t/cant-seem-to-assign-value-to-new-variable-within-if-statement-syntax-error-on-token-equal/54697/1 "2022-01-05T18:02:57Z")

</div>

First off, i apologize as i do need to get to reading more and figure these out on my own, but i’m on a mission here so any help is appreciated.

This is an expression linked to the background color in a multi state indicator.

I think the code should be pretty self explanatory, but obviously i am not getting something right.

“Syntax Error on Token: ‘EQUAL’” is the error i’m getting.

```python
if({[default]200FT Stripper/SS_PB/13SS_N-END-HAND_I5-13} && !{[default]200FT Stripper/SS_PB/17SS_STRIPPER-HAND-S-END_I6-12},
	northHandOnly = 1,
	northHandOnly = 0
)

if(!{[default]200FT Stripper/SS_PB/13SS_N-END-HAND_I5-13} && {[default]200FT Stripper/SS_PB/17SS_STRIPPER-HAND-S-END_I6-12},
	southHandOnly = 1,
	southHandOnly = 0
)

if(northHandOnly || southHandOnly,
	color (71,255,71),
	color (255,10,10)
)

```

---

<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:** [January 5, 2022, 6:06pm UTC](https://forum.inductiveautomation.com/t/cant-seem-to-assign-value-to-new-variable-within-if-statement-syntax-error-on-token-equal/54697/2 "2022-01-05T18:06:05Z")

</div>

Ignition expressions cannot do assignments. They are **just** expressions. An assignment to the bound property is implied (Imagine that property and an equal sign to the left of your first character in your expression).

---

<div class="post-metadata">

**Author:** ![Jacob\_Sanchez](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@Jacob\_Sanchez](https://forum.inductiveautomation.com/u/Jacob_Sanchez)\
**Post date:** [January 5, 2022, 6:10pm UTC](https://forum.inductiveautomation.com/t/cant-seem-to-assign-value-to-new-variable-within-if-statement-syntax-error-on-token-equal/54697/3 "2022-01-05T18:10:57Z")

</div>

I see, so in that case would i be able to use nested statements to accomplish the same thing?

---

<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:** [January 5, 2022, 6:15pm UTC](https://forum.inductiveautomation.com/t/cant-seem-to-assign-value-to-new-variable-within-if-statement-syntax-error-on-token-equal/54697/4 "2022-01-05T18:15:26Z")

</div>

I would use intermediate custom properties in place of the variables you’re using. Make boolean custom properties `northHandOnly` and `southHandOnly` on the indicator. Give them the conditions you have in the `if` blocks at the top.  
Then for the color, bind it using the last `if` statement you have, but using the custom properties in the condition.

---

<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:** [January 5, 2022, 6:18pm UTC](https://forum.inductiveautomation.com/t/cant-seem-to-assign-value-to-new-variable-within-if-statement-syntax-error-on-token-equal/54697/5 "2022-01-05T18:18:07Z")

</div>

> [@Jacob\_Sanchez](#):
>
> use nested statements

Not statements. Expressions. I'd do as Paul suggested, but you can make it a single expression if you don't mind multiple references to the same tags.

---

<div class="post-metadata">

**Author:** ![swolnisty](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@swolnisty](https://forum.inductiveautomation.com/u/swolnisty)\
**Post date:** [January 5, 2022, 6:18pm UTC](https://forum.inductiveautomation.com/t/cant-seem-to-assign-value-to-new-variable-within-if-statement-syntax-error-on-token-equal/54697/6 "2022-01-05T18:18:29Z")

</div>

Assuming that 17SS\_STRIPPER-HAND-S-END\_I6-12 is a boolean, I don’t see the point in checking whether it is true or false, when in each scenario you are setting another bit to true and then ultimately if either of the resulting bits are true you are ending up a with the same color. You could strip your code down to a much simpler expression:

```auto
if({[default]200FT Stripper/SS_PB/13SS_N-END-HAND_I5-13},
	color (71,255,71),
	color (255,10,10)
)

```

---

<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:** [January 5, 2022, 6:19pm UTC](https://forum.inductiveautomation.com/t/cant-seem-to-assign-value-to-new-variable-within-if-statement-syntax-error-on-token-equal/54697/7 "2022-01-05T18:19:29Z")

</div>

> [@swolnisty](#):
>
> I don’t see the point

It clearly excludes when both signals are on.

---

<div class="post-metadata">

**Author:** ![swolnisty](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@swolnisty](https://forum.inductiveautomation.com/u/swolnisty)\
**Post date:** [January 5, 2022, 6:20pm UTC](https://forum.inductiveautomation.com/t/cant-seem-to-assign-value-to-new-variable-within-if-statement-syntax-error-on-token-equal/54697/8 "2022-01-05T18:20:40Z")

</div>

I missed that exclamation point before the first tag in the second if statement. Ignore my previous post. 🙂
