# Script Interpretation

**URL:** <https://forum.inductiveautomation.com/t/script-interpretation/9176>\
**Category:** Ignition\
**Created:** [October 14, 2014, 4:08pm UTC](https://forum.inductiveautomation.com/t/script-interpretation/9176 "2014-10-14T16:08:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amarth](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarth/32/3313_2.png) [@Amarth](https://forum.inductiveautomation.com/u/Amarth)\
**Post date:** [October 14, 2014, 4:08pm UTC](https://forum.inductiveautomation.com/t/script-interpretation/9176/1 "2014-10-14T16:08:06Z")

</div>

Hi,

I’ve bumped into what I think being a problem with script interpretation. But I’m not sure if it is my interpretation or the compiler one. Here is the context.  
I’ve made a Gateway Script (Event Tag Change) in which I defined several functions. Some of them calling others inside the same script.

To make it simple, I’ve lightened the script :

[code]def func1(msg):  
return ‘result of func1("’ + msg + ‘")’

def func2(msg):  
return ‘result of func2("’ + func1(msg) + ‘")’

print func1(‘test’)  
print func2(‘test’)[/code]

Launching such a script in the Script Playground will generate an error :

```auto
NameError: global name 'func1' is not defined
```

Note that the error is generated by the line print func2(‘test’). The line print func1(‘test’) works correctly and outputs the expected result in the Script Playbround.

When I try to execute the same script on online compilers ([compileonline.com](http://www.compileonline.com/execute_jython_online.php) for exemple), the execution does not cause any error.

Has it something to do with the new global var scoping ?  
My Ignition version is 7.7.1

Thank you.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [October 20, 2014, 3:41pm UTC](https://forum.inductiveautomation.com/t/script-interpretation/9176/2 "2014-10-20T15:41:41Z")

</div>

Quite possibly it’s the script playground. It’s not specifically mentioned, but based on this thread, its more than likely.

[http://inductiveautomation.com/forum/viewtopic.php?f=72&t=8684&st=0&sk=t&sd=a&start=0](http://inductiveautomation.com/forum/viewtopic.php?f=72&t=8684&st=0&sk=t&sd=a&start=0)

After reading that, it looks like scoping was going to addressed for 7.7 with the new script namespaces (project and shared). If that’s the case, it’s possible the playground got overlooked.

I’d try sticking it into the one of the new namespaces and see what it does. 😃

---

<div class="post-metadata">

**Author:** ![Amarth](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarth/32/3313_2.png) [@Amarth](https://forum.inductiveautomation.com/u/Amarth)\
**Post date:** [October 23, 2014, 10:22am UTC](https://forum.inductiveautomation.com/t/script-interpretation/9176/3 "2014-10-23T10:22:06Z")

</div>

It works. Thank you very much for the tip.

Defining my functions in the project namespace did the trick. I could then call them from a Gateway script without problem.

![:thumb_right:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/2026e28c0c425034352c1b75807edf956adc75f4.gif ":thumb\_right:")
