# Quick IF Statement Question

**URL:** <https://forum.inductiveautomation.com/t/quick-if-statement-question/18508>\
**Category:** Ignition\
**Tags:** ignition79, scripting\
**Created:** [June 18, 2018, 1:47pm UTC](https://forum.inductiveautomation.com/t/quick-if-statement-question/18508 "2018-06-18T13:47:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomasdouglasshank](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/thomasdouglasshank/32/5486_2.png) [@thomasdouglasshank](https://forum.inductiveautomation.com/u/thomasdouglasshank)\
**Post date:** [June 18, 2018, 1:47pm UTC](https://forum.inductiveautomation.com/t/quick-if-statement-question/18508/1 "2018-06-18T13:47:08Z")

</div>

Hello Ignition forums!

I’m still new to this scripting, bare with my lack of knowledge.  
I’ll state my goal; I would like to have an indicator activate when ANY of the following conditions is true.  
PP = Parts Present  
I have PP1 through PP9 and need the indicator to show when ANY of the sensors have a part present.

This is the approach I took.

// If I use only the first IF statement it works.  
// Anytime I add more than one IF or OR the expression derps out.  
// UPDATE: I am receiving String Const Errors

if ({ST2010RA\_PU/Parts Present/1stPP Ind 0},  
‘(255,255,0)’, // True return GREEN  
‘(71,255,255)’ // False return BLUE  
)

| | ({ST2010RA\_PU/Parts Present/2ndPP Ind 0},  
‘(255,255,0)’, // True return GREEN  
‘(71,255,255)’ // False return BLUE  
)

| | ({ST2010RA\_PU/Parts Present/3rdPP Ind 0},  
‘(255,255,0)’, // True return GREEN  
‘(71,255,255)’ // False return BLUE  
)

4thPP Ind 0, 5thPP Ind 0 etc, are done similarly.

---

<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:** [June 18, 2018, 2:05pm UTC](https://forum.inductiveautomation.com/t/quick-if-statement-question/18508/2 "2018-06-18T14:05:24Z")

</div>

I’ve had a similar problem. Instead of using ORs try this

```auto
if expression
   statements
elif expression
   statements
elif expression
   statements
elif expression
   statements
```

you can see more on this syntax [here](https://www.tutorialspoint.com/python/nested_if_statements_in_python.htm)

---

<div class="post-metadata">

**Author:** ![thomasdouglasshank](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/thomasdouglasshank/32/5486_2.png) [@thomasdouglasshank](https://forum.inductiveautomation.com/u/thomasdouglasshank)\
**Post date:** [June 18, 2018, 2:10pm UTC](https://forum.inductiveautomation.com/t/quick-if-statement-question/18508/3 "2018-06-18T14:10:38Z")

</div>

I gave it a go but now I’m receiving a Bound Const Problem. Hopefully this image helps.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/81cfaf803c788cc362d72d95504346355f19c522.png)

---

<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:** [June 18, 2018, 2:16pm UTC](https://forum.inductiveautomation.com/t/quick-if-statement-question/18508/4 "2018-06-18T14:16:48Z")

</div>

I thought you were scripting, this is an expression. The expression binding has it’s own functions, and elif isn’t one. Can you post a pic of your original code. thanks

---

<div class="post-metadata">

**Author:** ![thomasdouglasshank](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/thomasdouglasshank/32/5486_2.png) [@thomasdouglasshank](https://forum.inductiveautomation.com/u/thomasdouglasshank)\
**Post date:** [June 18, 2018, 2:22pm UTC](https://forum.inductiveautomation.com/t/quick-if-statement-question/18508/5 "2018-06-18T14:22:30Z")

</div>

The original coding was ||'s instead of elif’s, and I knew it wouldn’t take me long to make a goof out of myself on here.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/7c2abeddb681ad95eef8c2f00f4a9f272bd52735.png) thank you for clarifying the difference.

---

<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:** [June 18, 2018, 2:24pm UTC](https://forum.inductiveautomation.com/t/quick-if-statement-question/18508/6 "2018-06-18T14:24:03Z")

</div>

> [@thomasdouglasshank](#):
>
> // If I use only the first IF statement it works.// Anytime I add more than one IF or OR the expression derps out.// UPDATE: I am receiving String Const Errors

From what I can tell from your code you should do this instead....

```auto
if( condition || condition2 || condition 3, true statement, false statement)

```

---

<div class="post-metadata">

**Author:** ![thomasdouglasshank](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/thomasdouglasshank/32/5486_2.png) [@thomasdouglasshank](https://forum.inductiveautomation.com/u/thomasdouglasshank)\
**Post date:** [June 18, 2018, 2:25pm UTC](https://forum.inductiveautomation.com/t/quick-if-statement-question/18508/7 "2018-06-18T14:25:24Z")

</div>

Oh woah, that makes a lot more sense. I need to work on my habits, I probably would’ve been able to see that if I wrote it out neater. Thank you so much dkhayes ^\_^. Just a final quesiton, this task is more suited for an expression correct?

---

<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:** [June 18, 2018, 2:32pm UTC](https://forum.inductiveautomation.com/t/quick-if-statement-question/18508/8 "2018-06-18T14:32:31Z")

</div>

> [@thomasdouglasshank](#):
>
> Just a final quesiton, this task is more suited for an expression correct?

An expression is fine. Any time you post code enclose the code with ["code"] and ["/code"] to format it. Exclude the quotes, I put them in so you can see the text. using the expression binding, click on the fx on the right side of the window will open a list of the expression functions and their syntax

---

<div class="post-metadata">

**Author:** ![thomasdouglasshank](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/thomasdouglasshank/32/5486_2.png) [@thomasdouglasshank](https://forum.inductiveautomation.com/u/thomasdouglasshank)\
**Post date:** [June 18, 2018, 2:34pm UTC](https://forum.inductiveautomation.com/t/quick-if-statement-question/18508/9 "2018-06-18T14:34:05Z")

</div>

Awesome man, thank you for the know hows 😄, This will definitely come in handy in the future, take it easy friend!
