I’m stuck in a couple of problems by Ignition 8.0.1.
The first Problem, I have been written a function in the Project Library, in this function I tried to get a data from a table component (table called data_result) in vision Project using the command :
data_result = event.source.parent.getComponent(‘result_table’).data
but it doesn’t work I got the error :
NameError: global name ‘event’ is not defined
The secon Problem that I could not call a function written in Project script using the value Change evnt of a Tag using a simple function “printHW()” and L2L is a script in Project Library:
NameError: global name ‘L2L’ is not defined
have any one a solution for those Problems!!!
If you want to use the event object in a project script function, you must pass it as a function argument from the event script that has it. The project script function should look something like this:
def someFunction(event, ....other args....):
# do something. Can use event object
And in the event script, you’d call that function like so:
someProjectScript.someFunction(event, ....other args....)
As for tag events, only the global scripting project’s scripts are available. If you’ve imported a v7.9 gateway backup, that would be set to contain the ‘shared.*’ scripts. (Those are the only scripts available to tag events in v7.x.) Tags aren’t in a project, so there’s no other way to have access to script modules.
If you’ve installed v8 fresh, there is no global scripting
module project by default. You’ll have to pick one.
thank you pturmel for your clarification and solution,
I still have Question About Global script module, how could I get this module, which module in Ignition is consist this feature to pick it ?
It’s not a module you install. It’s a project you create with scripting modules within, and then use the gateway configuration webpage to set it as the global scripting project.
I have no experiance with Ignition, I just started acouple of months ago, I’m developing a Special application for our platform, could you tell me please where I could find the Setting that could I used it to set the global Scripting Project in the Gateway configuration Webpage, I didn’t foud a such config!!
I tried this but it doesn’t work.
So you’ve found the right place, but you’re setting the global scripting project to a script library. Set this to the name of your project instead. Normally you would create an inheritable project, for example called Global, which you would use across multiple projects to store base functionality such as script libraries, templates, etc. Then you would set the global scripting project to this global project
To expand upon Nick’s answer:
I still have another Problem with ‘event’, now I’d like to use Event in Gatway Events, if I wrote the folowing in Timer or Tag Change in Gateway Event script:-
someProjectScript.someFunction(event, …other args…)
then I got the error:
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File “”, line 2, in NameError: name ‘event’ is not defined
how could I silve the Problem?
If you’re still trying to access a table on a page from this function that you’re calling from a gateway event script, you can’t do that. The table exists in a Window, and a Window is run on a frontend client. A gateway event script runs in the gateway process, and has no access to the frontend. If you want your clients to have access to your table data produced from this function, you should be wiring to a memory dataset type tag and binding your table
data property to the tag