Script Interpretation


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 :

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 ( 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.

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

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. :smiley:

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.