# Bind object property to multiple parameters?

**URL:** <https://forum.inductiveautomation.com/t/bind-object-property-to-multiple-parameters/43327>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [February 11, 2021, 8:40pm UTC](https://forum.inductiveautomation.com/t/bind-object-property-to-multiple-parameters/43327 "2021-02-11T20:40:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ali.Etezadkhah](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@Ali.Etezadkhah](https://forum.inductiveautomation.com/u/Ali.Etezadkhah)\
**Post date:** [February 11, 2021, 8:40pm UTC](https://forum.inductiveautomation.com/t/bind-object-property-to-multiple-parameters/43327/1 "2021-02-11T20:40:40Z")

</div>

Hi,

I’m trying to bind the liquidColor property of the cylindrical tank to 2 or more parameters in Perspective. For example if the “Hi” parameter is true to use orange, if “HiHi” is true use red, if “Lo” is true use yellow etc.

I tried multiple “If” statements, but adding the second statement causes an error. Case/switch wouldn’t work because it compares the value of a single parameter.

Thank you,  
Ali

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [February 11, 2021, 9:07pm UTC](https://forum.inductiveautomation.com/t/bind-object-property-to-multiple-parameters/43327/2 "2021-02-11T21:07:28Z")

</div>

Assuming your Hi, HiHi and Lo are bool’s, use binEnc() to combine them. It will return an int, that can be used in a case statement.

```auto
case(binEnc(tag1,tag2,tag3),
     0,"all false",
     1,"1,0,0",
     2,"0,1,0",
     4,"0,0,1",
    "default")

```

I believe you can also use the style to set the color based on the number returned from the binEnc().

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [February 11, 2021, 9:16pm UTC](https://forum.inductiveautomation.com/t/bind-object-property-to-multiple-parameters/43327/3 "2021-02-11T21:16:43Z")

</div>

You should use the Expression Structure binding. This allows you to bind multiple values into the Expression object. I always recommend including a transform after the Expression structure, like so (you could also use an expression structure if you prefer):

 ![Screen Shot 2021-02-11 at 1.15.45PM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/b/fbff5ac0c9dece8e7c3d8c7d190bef7e17c2315f.png)

---

<div class="post-metadata">

**Author:** ![Ali.Etezadkhah](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@Ali.Etezadkhah](https://forum.inductiveautomation.com/u/Ali.Etezadkhah)\
**Post date:** [February 11, 2021, 9:23pm UTC](https://forum.inductiveautomation.com/t/bind-object-property-to-multiple-parameters/43327/4 "2021-02-11T21:23:09Z")

</div>

That’s clever. Thank you.[quote=“bpreston, post:2, topic:43327, full:true”]  
Assuming your Hi, HiHi and Lo are bool’s, use binEnc() to combine them. It will return an int, that can be used in a case statement.

```auto
case(binEnc(tag1,tag2,tag3),
     0,"all false",
     1,"1,0,0",
     2,"0,1,0",
     4,"0,0,1",
    "default")

```

I believe you can also use the style to set the color based on the number returned from the binEnc().  
[/quote]

---

<div class="post-metadata">

**Author:** ![Ali.Etezadkhah](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@Ali.Etezadkhah](https://forum.inductiveautomation.com/u/Ali.Etezadkhah)\
**Post date:** [February 11, 2021, 9:35pm UTC](https://forum.inductiveautomation.com/t/bind-object-property-to-multiple-parameters/43327/5 "2021-02-11T21:35:33Z")

</div>

> [@cmallonee](#):
>
> You should use the Expression Structure binding. This allows you to bind multiple values into the Expression object. I always recommend including a transform after the Expression structure, like so (you could also use an expression structure if you prefer):
> 
> ![Screen Shot 2021-02-11 at 1.15.45PM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/b/fbff5ac0c9dece8e7c3d8c7d190bef7e17c2315f.png)

So this can be used to assign the values of 2 parameters to 2 variables. How can I use these variables to return a string for the color?

Let's say I bind variable 'a' to the 'Hi' param and 'b' to 'HiHi'. I end up with 2 boolean variables that match the boolean parameters. I need the output to be a string based on the state of the parameters/variables. This string would set the liquidColor property of the cylindrical tank. What is the operator I would need to evaluate these 2 (or more) variables and map to a string?

Thanks,  
Ali

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [February 12, 2021, 1:27am UTC](https://forum.inductiveautomation.com/t/bind-object-property-to-multiple-parameters/43327/6 "2021-02-12T01:27:15Z")

</div>

That’s what you use the transform for. You can specify any logic and return you’d like in the transform, so you could do something like

```auto
color = '#FFFF00'. # default to yellow, or you can wrap this in logic.
if value['a']:
    color = '#FFA500' # if "Hi", then use orange
if value['b']:
    color = '#FF0000' # if "HiHi" then use red
return color

```
