# Embedded if statements

**URL:** <https://forum.inductiveautomation.com/t/embedded-if-statements/83697>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [January 2, 2024, 5:51pm UTC](https://forum.inductiveautomation.com/t/embedded-if-statements/83697 "2024-01-02T17:51:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael.black](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@michael.black](https://forum.inductiveautomation.com/u/michael.black)\
**Post date:** [January 2, 2024, 5:51pm UTC](https://forum.inductiveautomation.com/t/embedded-if-statements/83697/1 "2024-01-02T17:51:47Z")

</div>

Using vision version 8.21

I have no control over what is in the plc but I need to do the following:

Create four maintained PB's which each have their own boolean tag value, for example: Bool1, Bool2, Bool3, and Bool4  
Create one label with a script on the text field to do the following:  
if Bool1 is true, text will say 'Bool1',  
if Bool2 is true, text will say 'Bool2',  
if Bool3 is true, text will say 'Bool3',  
if Bool4 is true, text will say 'Bool4',  
else have text say 'None' as failsafe if none of true

Within the plc program if one boolean goes high the others go low so there is never a situation where two booleans can be true at the same time.

I attempted to create the following but its telling me the if statement cant have four arguments...

if (Bool1, 'Bool1', if(Bool2, 'Bool2', 'None'), 'None')

Any suggestions on how to do this easily?

---

<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 2, 2024, 5:55pm UTC](https://forum.inductiveautomation.com/t/embedded-if-statements/83697/2 "2024-01-02T17:55:10Z")

</div>

You want `binEnum` paired with `case`:  
[https://docs.inductiveautomation.com/display/DOC81/binEnum](https://docs.inductiveautomation.com/display/DOC81/binEnum)  
[https://docs.inductiveautomation.com/display/DOC81/case](https://docs.inductiveautomation.com/display/DOC81/case)

```auto
case(
	binEnum({Bool1}, {Bool2}, {Bool3}, {Bool4}),
	1, 'Bool1',
	2, 'Bool2',
	3, 'Bool3',
	4, 'Bool4',
	"Default"
)

```

---

<div class="post-metadata">

**Author:** ![michael.black](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@michael.black](https://forum.inductiveautomation.com/u/michael.black)\
**Post date:** [January 2, 2024, 6:06pm UTC](https://forum.inductiveautomation.com/t/embedded-if-statements/83697/3 "2024-01-02T18:06:02Z")

</div>

Perfect thanks! Had to throw a comma after the binEnum function too
