Timer script issue

Hi,
I have a timer placed in classic chart and i have return 1244 lines… but it showing error … how many lines can we able to write script in timer component? if i delete some lines its not showing error… how to fix this issue?
@Kevin.Herron can you give solution for my issue?


error showing like this

Can you provide any more details about the error, ideally the entire stacktrace?

There’s no explicit limit to the number of characters or lines a script can be, so that’s likely not related.

Parse error for event handler "propertyChange" java.lang.RuntimeException: Encountered too large method code in <string> Please provide a CPython 2.7 bytecode file (.pyc) to proceed, e.g. run python -m py_compile <string> and try again. Alternatively provide proper CPython 2.7 execute command via cpython_cmd property, e.g. call jython -J-Dcpython_cmd=python or if running pip on Jython: pip install --global-option="-J-Dcpython_cmd=python" <package> at org.python.compiler.Module.loadPyBytecode(Module.java:838) at org.python.compiler.Module.compile(Module.java:935) at org.python.compiler.Module.compile(Module.java:701) at org.python.compiler.LegacyCompiler$LazyLegacyBundle.ostream(LegacyCompiler.java:59) at org.python.compiler.LegacyCompiler$LazyLegacyBundle.loadCode(LegacyCompiler.java:43) at org.python.core.CompilerFacade.compile(CompilerFacade.java:33) at org.python.core.Py.compile_flags(Py.java:2171) at org.python.core.Py.compile_flags(Py.java:2176) at org.python.core.Py.compile_flags(Py.java:2206) at com.inductiveautomation.factorypmi.designer.eventhandling.ComponentScriptEditor.applyChanges(ComponentScriptEditor.java:519) at com.inductiveautomation.factorypmi.designer.eventhandling.ComponentScriptEditor$5.actionPerformed(ComponentScriptEditor.java:344) at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source) at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.desktop/java.awt.Component.processMouseEvent(Unknown Source) at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source) at java.desktop/java.awt.Component.processEvent(Unknown Source) at java.desktop/java.awt.Container.processEvent(Unknown Source) at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source) at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source) at java.desktop/java.awt.Component.dispatchEvent(Unknown Source) at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source) at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source) at java.desktop/java.awt.Component.dispatchEvent(Unknown Source) at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.desktop/java.awt.EventQueue$4.run(Unknown Source) at java.desktop/java.awt.EventQueue$4.run(Unknown Source) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.desktop/java.awt.EventQueue$5.run(Unknown Source) at java.desktop/java.awt.EventQueue$5.run(Unknown Source) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.desktop/java.awt.EventDispatchThread.run(Unknown Source) java.lang.RuntimeException: java.lang.RuntimeException: Encountered too large method code in <string> Please provide a CPython 2.7 bytecode file (.pyc) to proceed, e.g. run python -m py_compile <string> and try again. Alternatively provide proper CPython 2.7 execute command via cpython_cmd property, e.g. call jython -J-Dcpython_cmd=python or if running pip on Jython: pip install --global-option="-J-Dcpython_cmd=python" <package>

Does jython still have the limitation that a single method must compile to fit 64k ?

If so, break your script up into functions and place them in a script module (should do this anyways).

2 Likes

Huh, interesting, I’ve honestly never run into that. As Phil suggested, your best path forward is to break up your code into different function(s) in the project library and just call those functions from your component event scripts.

For me its difficult to break the code to functions… Because i am using jfree scripting to chart… To do alots of customization… Is there any other way to fix it? @pturmel @PGriffith

Not that I’m aware.

There’s a rule of thumb for programming that any given function should be no more that a couple pages or so on-screen. Any more than that should be refactored into separate, smaller, easier-to-understand functions. I find it hard to believe that can’t be done.

1 Like

Ok thanks for the information. I will try to convert it to functions😔

you can import multiple modules from a source in one line separating by comma

from java.awt import Font, Color, Paint
i see below you did the same for geom,
its already a few lines off :stuck_out_tongue:

1 Like

ha ha ha that’s also good point. i will do it one line :sweat_smile:

1 Like