Ignition script editor, it kinda sucks

I’ve been learning to use ignition for the last few months. The Designer is honestly pretty good. It’s flexible, so flexible that you could possibly make programmes that aren’t just about SCADA and such.
However one of my biggest pet peeves in using the Designer has been the script editor.

The script editor lacks so many basic features most other programming focused editors have. Automatic construction of commonly used multi line functions like loops, collapsing groups of code and my personal worst, no indentation lines.
Especially since (P/J)ython relies on indentation to order it’s code. The amount of times I couldn’t tell what was going wrong simply because my indents were wrong is staggering.

I’m wondering what you all think about this? Are there some simple solutions I’m not aware of maybe? Or do we all just silently struggle?

1 Like

Pretty much. Particularly for event scripts, and for troubleshooting.

I tend to do bulk editing of script modules in Kate with a compatible modeline, then paste the whole thing into Ignition. Pasting the whole thing avoids the garbled indentation from selective pasting. /:

1 Like

Fair enough. I’m personally not very familiar with most of the Ignition specific functions yet, so I have been making use of the script editor for those few helpful Ignition specific features it does have.

I did find an interesting thread about someone who had made a library of mock system functions however. Ignition mock scripts on GitHub

Still, it’d be perfect if you were somehow able to make use of you editor of choice in the Designer itself.

Tough to do that in a cross-platform way, at least from Java. Someday, far in the future, browser technologies will cover all the bases, even for the designer. Ten years, perhaps, kinda like fusion power… /:

3 Likes

Once we are used to IDE’s with features like intellisense etc. we feel handicapped without them. However its too much to expect Ignition script editor to be an IDE! What is supported itself is unprecedented ! No other SCADA supports scripting! This in my opinion is the best feature of Ignition that makes it flexible and extendable. Imagine days when we used to write code using plain text editors like ed and vi!

However I think some basic features of editor like search/replace should be supported. It will make life a lot easier for a developer.

1 Like

Fair enough.
I’d personally be satisfied with two things: Indentations lines and collapsible groups of code.

Just having these two features would be so nice both during writing and when looking back at already written code. It would allow me to declutter event scripts and make it a lot easier to handel indentation.

Agreed, I think some of these are already in pipeline in Ignition’s road-map when I wrote to them on this topic last time.

However I think the script code is not going to be huge, running into 1000’s of lines! You can achieve so much with small scripts due to power of python and the rich set of library of well thought out functions supported by Ignition. So guess its manageable without advanced features like collapsible grouping of code etc. That’s just my view, but of course more the features the merrier it is for a developer.

1 Like

Blockquote
…collapsible groups of code.

You can collapse a code block by highlighting it and doing a CTRL + >

Another favorite to get previous clipboard items:
CTRL + Shift + V

Consider commenting/voting here: https://ideas.inductiveautomation.com/ignition-features-and-ideas/p/script-editor-improvments.

Also see this one: https://inductiveautomation.canny.io/ignition-features-and-ideas/p/break-points-and-a-good-debugger. @KathyApplebaum, am I reading your last Sep. 20 comment on this one correctly as suggesting we will be able to use our editor of choice for scripts soon?

What she means is now that many of the script resources are saved to the filesystem in .py files you can open and edit them with whatever editor you’d like (assuming you’re on the gateway machine). You can save changes to the file on the filesystem and they will be picked up by Ignition.

4 Likes

Thanks @Kevin.Herron. Would it make sense to have a setting somewhere to set path to desired script editor and then have right-click->Scripting as well as library scripts open with that editor?

I don’t really mind it to be honest. It’d be cool if there was a way to link up Ignition with VS Code somehow but I have no idea if that’s even feasible.

Working with external editors would basically require the designer writing resources you’re editing to disk, which would be a change to resource editing similar in scale with the changes to resource storage on the gateway that happened in 8.0. It’s possible, and something we have looked into, but it’s also definitely not a trivial change to make.

4 Likes

You’re right, I had no idea.
However, after being collapsed they aren’t retained in their collapsed state after closing the editor and there’s no way to distinguish different collapsed groups of code.

that being said, it’s better than nothing.

Maybe someday in the future then?

I don’t know much about how Ignition was built, so I don’t know if these features would be harder to implenent than making it possible to work with external editors.

Thank you pturmel for reference to Kate - it’s superior to notepad++ for scripts, which I have already been using.

I like how Kate subtly shows embedded tabs. I just spent 2 days debugging a copy of proven code ruined by auto-indents-from-hell (AIFH). Now to install it on all the machines I use…

If someone is stuck with built-in script editor, my “work-around” has been to add additional comment lines for key keywords that used the left-margin as a hard reference - that made correcting AIFH give reliable (more) results. Example:

####################else
 					else:
 					 	logger.info( "AOV304_Opened value = 0 but poor sum (for average) quality")
################except:
 				except:
 					logger.info("AOV304_Opened initial = 0, value = 1, begin = %s vs end = %s which FAILED TO SUBTRACT" % (time_now,startedTAG.value) )
 					# From http://www.perfectabstractions.com/blog/debugging-and-testing-gateway-event-scripts
 					import sys
 					from java.lang import Exception
 					exceptionType, exception, stacktrace = sys.exc_info()
 					if exceptionType == Exception:
 						exception = exception.getCause()
 					exceptionName = exception.__class__.__name__
 					logger.error(exceptionName+" : "+str(exception))
############else
 			else:
 				logger.info( "AOV304_Opened value = 0 but poor started quality")
########else			
 		else:
 			logger.info( "AOV304_Opened initial = 0 but unrecognized newValue.value (newValue = %s" % (newValue) )
1 Like

No install required if you run Kubuntu or other KDE-flavored Linux (: