# Perspective Property binding and scripting parse error

**URL:** <https://forum.inductiveautomation.com/t/perspective-property-binding-and-scripting-parse-error/62144>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [July 20, 2022, 8:05pm UTC](https://forum.inductiveautomation.com/t/perspective-property-binding-and-scripting-parse-error/62144 "2022-07-20T20:05:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike4](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@mike4](https://forum.inductiveautomation.com/u/mike4)\
**Post date:** [July 20, 2022, 8:05pm UTC](https://forum.inductiveautomation.com/t/perspective-property-binding-and-scripting-parse-error/62144/1 "2022-07-20T20:05:33Z")

</div>

Hi, I’m having trouble with my scripting to change the background color of some components.  
I am a beginner at python so any advice would be greatly appreciated!

My goal is to turn the background color of each of the Red/Yel/Grn components 1 of 2 colors.  
If the custom property “Light\_On” is true,then turn the background color to “Light\_Color\_On” (#0000FF)  
If the custom property “Light\_On” is false,then turn the background color to “Light\_Color\_Off” (#0000FF80)

Currently, I have tried the following script after a Property binding, but I keep getting an error:

```
                   Error_Configuration("Parse Error in script transformation")

```

```auto
def transform(self, value, quality, timestamp):
	
	newcolor = self.custom.Light_Color_On # "#FFFF00"
	oldcolor = self.custom.Light_Color_Off # "#FFFF0080"
	
	if value:
		returncolor = newcolor
	else
		returncolor = oldcolor
	return returncolor

```

Not sure what my error is or how to fix it.

Please and thank you!

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

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 20, 2022, 8:11pm UTC](https://forum.inductiveautomation.com/t/perspective-property-binding-and-scripting-parse-error/62144/2 "2022-07-20T20:11:16Z")

</div>

You are missing the colon after you else.

```auto
If value:
    #do something
else:
    #do something else

```

---

<div class="post-metadata">

**Author:** ![mike4](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@mike4](https://forum.inductiveautomation.com/u/mike4)\
**Post date:** [July 20, 2022, 8:14pm UTC](https://forum.inductiveautomation.com/t/perspective-property-binding-and-scripting-parse-error/62144/3 "2022-07-20T20:14:01Z")

</div>

Thank you! As I said, I am very beginner level.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 20, 2022, 8:26pm UTC](https://forum.inductiveautomation.com/t/perspective-property-binding-and-scripting-parse-error/62144/4 "2022-07-20T20:26:32Z")

</div>

No problem, though the more Pythonic way to write this script would be:

```auto
if value:
    return self.custom.Light_Color_On
return self.custom.Light_Color_Off

```

The better way to do this in Ignition would be to use an expression binding with this expression:

```auto
if(self.custom.Light_On,self.custom.Light_Color_On, self.custom.Light_Color_Off)

```

Better yet would be to use CSS theme variables so that you don’t have hard coded “magic” colors.
