Global Variables are not recognized in functions in "Gateway Events Scripts"

This is not really a bug, but it is annoying. Gateway event scripts use legacy python scope rules that prevent any names in the top level event scope from being captured in nested functions’ closures. (Ignition v8 would have been a good choice to drop the backward compatibility…)

If you find you need to define a nested function within a gateway event script, you probably should move the whole thing to a project script module. Then your gateway event becomes a one-liner, something like so:

[project.]someScript.someFunction(event)

Script modules use modern python scoping and will properly form closures for nested function definitions.

1 Like