# Script Modules and Property Bindings

**URL:** <https://forum.inductiveautomation.com/t/script-modules-and-property-bindings/5703>\
**Category:** Ignition\
**Created:** [January 18, 2013, 10:40pm UTC](https://forum.inductiveautomation.com/t/script-modules-and-property-bindings/5703 "2013-01-18T22:40:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![agueorguiev](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@agueorguiev](https://forum.inductiveautomation.com/u/agueorguiev)\
**Post date:** [January 18, 2013, 10:40pm UTC](https://forum.inductiveautomation.com/t/script-modules-and-property-bindings/5703/1 "2013-01-18T22:40:57Z")

</div>

I have a script that updates both the data and the columnAttributesData of a table, among other things. Because I’m setting multiple values with the same script, I can’t simply return a value but have to set it through the script itself.

As it is right now, I have to both link the location of the triggering property as well as type out the name of the window (property bindings don’t seem to be able to see the window’s name). I’d like to make the whole process a bit more efficient by having the calling property’s and the window’s names be automatically generated within the script.

Am I wasting my time trying to find a solution to my problem or is there something I’ve overlooked?

Essentially, what I want to get to is this:  
Exception: Error executing expression binding on  
Window.Root Container.Button.text  
caused by ExpressionException: Error executing script for runScript() expression:app.testing.test()  
caused by Traceback (most recent call last):  
File “expression:runScript”, line 1, in   
File “module:testing”, line 16, in test  
ZeroDivisionError: integer division or modulo by zero  
But I’m not sure how to get that data from within the script.

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [January 21, 2013, 8:28pm UTC](https://forum.inductiveautomation.com/t/script-modules-and-property-bindings/5703/2 "2013-01-21T20:28:41Z")

</div>

Do you remind posting your app.testing.test() script? Also, since you’re binding to a text property, you need to return a string from that script, is test() returning a string?

---

<div class="post-metadata">

**Author:** ![agueorguiev](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@agueorguiev](https://forum.inductiveautomation.com/u/agueorguiev)\
**Post date:** [January 21, 2013, 9:58pm UTC](https://forum.inductiveautomation.com/t/script-modules-and-property-bindings/5703/3 "2013-01-21T21:58:03Z")

</div>

It was supposed to fail, the entirety of app.testing was:

`def test():
        1/0`

What I’m trying to get to with the actual script is the “Window.Root Container.Button.text” returned at the beginning of the exception. How can I get this path from within the script module?

Currently I’m relying on this secondary script to get the source, but I was hoping there is an easier way to find the location of the calling property, since the exception handler is able to do it. It would save me a lot of time by not having to retype the window name and the property’s source every time because I don’t have the option of quickly doing this through xml.

`def Source(win,src,parent=0):
        import system
        srcLen = len(src)
        if parent < 0 or parent+1 > srcLen: parent = 0
        try: attributeData = system.gui.getWindow(str(win)).rootContainer
        except: return
        for x in range(srcLen-parent):
                if x == srcLen-1: attributeData = getattr(attributeData,src[x])
                else: attributeData = attributeData.getComponent(src[x])
        return attributeData`

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [January 22, 2013, 9:35pm UTC](https://forum.inductiveautomation.com/t/script-modules-and-property-bindings/5703/4 "2013-01-22T21:35:08Z")

</div>

There is currently no way to reference from a script which property called it. You will have to pass a parameter in the function call, or use your current solution.
