Scope for methods defined in Gateway Event Script

Ignition 8.0.10

I’ve put the following code in a gateway timer script and in the action performed event handler of a vision client button. In the vision button it performs exactly how I expect it would, printing to the console. In the gateway script I expected to see a print out in the wrapper.log file, but I didn’t. I instead got

NameError: global name 'testVar' is not defined

I must be misunderstanding some nuance of scoping in gateway event scripts. Could someone point me in the right direction toward understanding this?

testVar = 'Test'
def test_function():
	print testVar
test_function()

Yup. Legacy scoping for ancient backwards compatibility. IA missed an opportunity to fix this with v8. /:

You’ll want to place your code in a regular script module and call it from the event, passing the event variable(s) as function arguments.

Since a gateway event script is associated with a project, can a project level script module be used or does it require a gateway accessible script module?

Project scripts are fine. That’s one of the reasons I prefer (and recommend) gateway tag change events (in the project) over Value/Quality/Timestamp tag events (not in a project).

Thanks for help. It really through me for awhile.