# Problem with an if statement in a script

**URL:** <https://forum.inductiveautomation.com/t/problem-with-an-if-statement-in-a-script/111791>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [October 29, 2025, 3:32pm UTC](https://forum.inductiveautomation.com/t/problem-with-an-if-statement-in-a-script/111791 "2025-10-29T15:32:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve.lankford](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@steve.lankford](https://forum.inductiveautomation.com/u/steve.lankford)\
**Post date:** [October 29, 2025, 3:32pm UTC](https://forum.inductiveautomation.com/t/problem-with-an-if-statement-in-a-script/111791/1 "2025-10-29T15:32:19Z")

</div>

I have a simple script bound to the text of a label.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/1/41cd5bb125ddbcfc7bd81c3d555e85a3b90b413d.png)

This is the result that I am getting:

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/4/6434056464dfef3f2f72437a031f25d5fbc63392.png)

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [October 29, 2025, 3:35pm UTC](https://forum.inductiveautomation.com/t/problem-with-an-if-statement-in-a-script/111791/2 "2025-10-29T15:35:49Z")

</div>

What type of value is {self.view.params.ShowManualUpDown} ?

I would try to explicitly check the value of the param

if self.view.params.ShowManualUpDown==True:

---

<div class="post-metadata">

**Author:** ![steve.lankford](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@steve.lankford](https://forum.inductiveautomation.com/u/steve.lankford)\
**Post date:** [October 29, 2025, 3:38pm UTC](https://forum.inductiveautomation.com/t/problem-with-an-if-statement-in-a-script/111791/3 "2025-10-29T15:38:36Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/f/8f220aff9db39c837172e69b064b8d3d909fc878.png)

```python
    text = 'ShowManualUpDown is '
    text = text + str(self.view.params.ShowManualUpDown) + '. '
    if self.view.params.ShowManualUpDown == True:
        text = text + 'It took the true path.'
    else:
        text = 'It took the false path.'
    return text

Gives the same result.

```

---

<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:** [October 29, 2025, 3:41pm UTC](https://forum.inductiveautomation.com/t/problem-with-an-if-statement-in-a-script/111791/4 "2025-10-29T15:41:07Z")

</div>

```python
self.view.params.ShowManualUpDown) + '. '
    if self.view.params.ShowManualUpDown

```

You're reading the property two times. Something else is acting on it in between. This is a data race.  
If you want the value to be constant, bind it to a local variable:

```python
text = 'ShowManualUpDown is '
manualValue = self.view.params.ShowManualUpDown
text = text + str(manualValue) + '. '
if manualValue == True:
    text = text + 'It took the true path.'
else:
    text = 'It took the false path.'
return text

```

---

<div class="post-metadata">

**Author:** ![steve.lankford](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@steve.lankford](https://forum.inductiveautomation.com/u/steve.lankford)\
**Post date:** [October 29, 2025, 3:44pm UTC](https://forum.inductiveautomation.com/t/problem-with-an-if-statement-in-a-script/111791/5 "2025-10-29T15:44:38Z")

</div>

```python
def transform(self, value, quality, timestamp):
    tmp = ( self.view.params.ShowManualUpDown)
    text = 'ShowManualUpDown is '
    text = text + str( tmp) + '. '
    if tmp:
        #text = UP_SP_LIFT_Status_Text.State(value, False, False)    
        text = text + 'It took the true path.'
    else:
        #text = UP_SP_STD_Status_Text.State(value, False, False)
        text = 'It took the false path.'
    return text

```

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/7/37ab1a5c79ab026533fac0549bde17706f59970f.png)

Same result.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [October 29, 2025, 3:47pm UTC](https://forum.inductiveautomation.com/t/problem-with-an-if-statement-in-a-script/111791/6 "2025-10-29T15:47:27Z")

</div>

Are you actually passing a boolean to the parameter? Perhaps a string is being passed and then coerced into a boolean during the check.

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [October 29, 2025, 3:47pm UTC](https://forum.inductiveautomation.com/t/problem-with-an-if-statement-in-a-script/111791/7 "2025-10-29T15:47:28Z")

</div>

If ShowManualUpDown was an actual boolean, `str(ShowManualUpDown)` would be “False” not “false.” If it’s the string “false” then it would evaluate as True in a boolean expression.

---

<div class="post-metadata">

**Author:** ![steve.lankford](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@steve.lankford](https://forum.inductiveautomation.com/u/steve.lankford)\
**Post date:** [October 29, 2025, 4:10pm UTC](https://forum.inductiveautomation.com/t/problem-with-an-if-statement-in-a-script/111791/8 "2025-10-29T16:10:25Z")

</div>

That’s the problem. It is being passed in as string and not a Boolean.

I am invoking it with:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/f/cf0cc0868fbfa5eeeb221eb4427f3ab6e5d68049.png)

That is passing it as a string.

Thank you everyone for your help and suggestions on this.

---

<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:** [October 29, 2025, 8:54pm UTC](https://forum.inductiveautomation.com/t/problem-with-an-if-statement-in-a-script/111791/9 "2025-10-29T20:54:12Z")

</div>

~~You're over cookng this one. You shouldn't be using a script transform _at all_ here to do a simple, what turns out to be, text concatenation. Script transforms are a last resort if you can't do it another way as they require more resources and time to process.~~

~~This should use an expression binding with:~~

```python
'ShowManualUpDown is ' + toStr({self.view.params.ShowManualUpDown}) + '. It took the' +({self.view.params.ShowManualUpDown} = True) + ' path' 

```

Edit: Oh wait I think I missed the point haha. It was obviously a test, but I didn't appreciate that it was a test checking the data type of that param.

However, my comment still stands about using expressions over script transforms.
