Gateway Events - Scheduled Scripts

Hi,

I’m trying to run a Gateway Scheduled Script that calls a function inside a Script that is define in the Project Library. It works from a button actionperformed script but is not working in the Gateway Scheduled Script. Also I did the INDENT

This is the Script;

def onScheduledEvent():
“”"
A scheduled script that will execute periodically on the gateway.

"""
KPIs.myKPIs()

This is the Error when looking on the Gateway Status;

org.python.core.PySyntaxError: SyntaxError: (“mismatched input ‘KPIs_Script’ expecting INDENT”, (’’, 2, 0, ‘KPIs_Script.myKPIs()\n’))

at org.python.core.ParserFacade.fixParseError(ParserFacade.java:95)

at org.python.core.ParserFacade.parse(ParserFacade.java:205)

at org.python.core.Py.compile_flags(Py.java:2205)

at com.inductiveautomation.ignition.common.script.ScriptManager.compileFunction(ScriptManager.java:899)

at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$TrackingProjectScriptManager.compileFunctionSuper(ProjectScriptLifecycle.java:638)

at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$AutoRecompilingScriptFunction.getOrCreateDelegate(ProjectScriptLifecycle.java:737)

at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$AutoRecompilingScriptFunction.(ProjectScriptLifecycle.java:728)

at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$TrackingProjectScriptManager.compileFunction(ProjectScriptLifecycle.java:623)

at com.inductiveautomation.ignition.common.script.ScheduledScriptManager$ScheduledScriptTask.run(ScheduledScriptManager.java:133)

at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.base/java.lang.Thread.run(Unknown Source)

Please edit your post, highlight your pasted code, and click the “Preformatted text” button–looks like this: </>. Then we can see its indentation, the quotes won’t turn into curly unicode substitutes, and my old eyes won’t hurt. /:

org.python.core.PySyntaxError: SyntaxError: (“mismatched input ‘KPIs_Script’ expecting INDENT”, (’’, 2, 0, ‘KPIs_Script.myKPIs()\n’))

You have a syntax problem. It seems like you may have

def onScheduledEvent():
KPIs.myKPIs()

But it should be

def onScheduledEvent():
    KPIs.myKPIs()

But it’s hard to tell. Format your code. You can also use three backticks to format your code

```

your code here

```

Yeah, Thanks. I deleted the Scheduled Script, create a new one with a different name and it works. I think somehow the gateway got stuck with the old script.