# Struggling to build an expression

**URL:** <https://forum.inductiveautomation.com/t/struggling-to-build-an-expression/88381>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [April 4, 2024, 9:31pm UTC](https://forum.inductiveautomation.com/t/struggling-to-build-an-expression/88381 "2024-04-04T21:31:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![brians.laptop](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/brians.laptop/32/27906_2.png) [@brians.laptop](https://forum.inductiveautomation.com/u/brians.laptop)\
**Post date:** [April 4, 2024, 9:31pm UTC](https://forum.inductiveautomation.com/t/struggling-to-build-an-expression/88381/1 "2024-04-04T21:31:28Z")

</div>

Last time, I learned about BinEnc. I'd like to take it a bit further and need help with the syntax.

I have 2 DINTS...  
If DINT 1 \> 0... 1  
if DINT 2 \> 0... 1  
Then, BinEnc(DINT 1 Result, DINT 2 Result)

How do I write that? I'm using it to change the color and text of a multi-state indicator.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [April 4, 2024, 9:40pm UTC](https://forum.inductiveautomation.com/t/struggling-to-build-an-expression/88381/2 "2024-04-04T21:40:13Z")

</div>

```auto
binEnc(
	DINT_1 > 0,
	DINT_2 > 0
)

```

However, you might want to use this state elsewhere. If these 2 DINTs are part of a UDT (which they probably should be, since it seems like they are related), you can make an expression tag and bind to that to control your style customizer.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 4, 2024, 9:43pm UTC](https://forum.inductiveautomation.com/t/struggling-to-build-an-expression/88381/3 "2024-04-04T21:43:13Z")

</div>

To expand further,

```auto
case(
  binEnc(
    DINT_1 > 0,
    DINT_2 > 0
  ), // value to inspect
  0, "Off", // case 0, return 0
  1, "Running", // case 1, return 1
  2, "Fault", // case 2, return 2
  "BAD STATE!" // default return
)
```

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [April 4, 2024, 9:44pm UTC](https://forum.inductiveautomation.com/t/struggling-to-build-an-expression/88381/4 "2024-04-04T21:44:13Z")

</div>

This would work, if you wanted to do a binding for each property, but I think @brians.laptop just wants the resulting INT so he can use it in a style customizer (or at least that's what he _should_ do).

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 4, 2024, 9:46pm UTC](https://forum.inductiveautomation.com/t/struggling-to-build-an-expression/88381/5 "2024-04-04T21:46:04Z")

</div>

Brians should probably add the `vision` or `perspective` tag to his original question!

---

<div class="post-metadata">

**Author:** ![brians.laptop](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/brians.laptop/32/27906_2.png) [@brians.laptop](https://forum.inductiveautomation.com/u/brians.laptop)\
**Post date:** [April 5, 2024, 2:49am UTC](https://forum.inductiveautomation.com/t/struggling-to-build-an-expression/88381/6 "2024-04-05T02:49:32Z")

</div>

Thanks to both of you. Its pretty simple stuff... but I'm trying to copy the functions on an existing Red Lion HMI, on a similar plastic sheet extruder. One DINT has 32 warnings, and the other DINT has 32 alarms. Green: No Alarms, Yellow: Active Warnings, Red: Active Alarms. If there are both, warnings and alarms, then the flasher flashes Yellow and Red for 1000 ms each. Thanks again for the info.
