Gateway Tag Change Script Function Call Weird

Weird! Function cannot see other Functions.
WHAT IS GOING ON?

I have the following code:

ERROR:

line 6, in function2 NameError: global name 'function1' is not defined

line 9, in function3 NameError: global name 'event' is not defined

line 12, in function4 NameError: global name 'system' is not defined

why oh why?!

Legacy scoping issue.

Do not use def inside gateway event scripts. In my not-so-humble opinion, you should not use def (or import) in any event script. Make a one-line call to a project library script, passing any necessary arguments in the function call. Always.

4 Likes

Lol, my bad.

[quote="pturmel, post:2, topic:112058"]
Make a one-line call to a project library script,
[/quote]

me, wanting to skip the explanation why I have such script in project library to team lead, and skip the decision of a proper place to store it in Project Library.

THANKs for fast response.

For posterity (I know Phil knows this, but for the OP and anyone who comes across this thread in the future) - that legacy scoping issue is fixed in 8.3.0 and up.

3 Likes

Indeed, but there are performance reasons for my one-liner event advice, too. I will continue harping on it.

4 Likes