Question About runScript

Hello! I have been wanting to see if I can simply run a script on button press. I have been trying to play around with:

 runScript(scriptFunction, [pollRate], [arg1], [arg2], [arg...]) 

I'm trying to run a Script stored on the gateway I'm assuming. It's in the scripting section in the project browser.

The code I'm using is:

 runScript(EmailSummary)

But its not working. I'm getting a

com.inductiveautomation.ignition.common.script.JythonExecException
Traceback (most recent call last):
  File "<function:runAction>", line 2, in runAction
NameError: global name 'runScript' is not defined

Is this not supported or am i using this syntax wrong?

The runScript() function is for expression bindings. Not for event scripts. Event scripts are already in jython form--they don't need an interface to call other jython.

Next, calling EmailSummary is certainly not going to be correct by itself. Script library modules need to have function definitions within them to be useful, and you would call EmailSummary.someFunction(). Code that runs at the outermost level (outside a def) of a library script is initialization for the persistent parts of the script. It is not where callable code is placed.

2 Likes