Script cross reference

I have recently inherited a project that has a fair amount of scripting, and I am being tasked with extending the project to account for additional equipment that fits the pattern of existing equipment.

In reviewing the application, it appears that the original author (now unavailable) had some decent Python skills, but was relatively new to Ignition. There appears to be some artifact code, but it’s been painstaking, using the Find/Replace tool to search for where script functions are called.

If I was in classical, pure text based programming environment, and didn’t have an IDE that provided some level of function call cross reference, I might do something like create a file of function names, and then grep/bash script my way into a useful cross reference.

But that’s not possible (insofar as I know) with Ignition. I tried doing a project export, and though that does export all script in the project, it can’t account for Gateway Scripts or inherited project scripts (I think), and it looks like it can’t peer into such things as tag change events.

I’ve seen some other stale topics on this subject that all seem to end in “just use the Find/Replace tool”, but really, this seems to fall short. So I’d like to resurect this and put it on the developer storyboard if possible.

As an aside, wrt using the Search/Replace tool, the main-menu search replace item indicates use of the Ctrl-F hot key, but when inside a script, this hot key actually brings up a different Find/Replace dialog that’s not useful for what I want to do.

Just saw the this for feature requests; added it.

There may be some magic I’m missing, but I find the built-in find/replace to be lacking. I tend to trust recursive command line grep of the whole project directory more, with the big caveat that it will miss things in binary blobs (older named SQL queries, reports, alarm pipelines, gateway events, and others).

As a consequence, I try to keep scripting in those locations to an absolute minimum. My gateway events are always a single call to a function in a plaintext script file.

Also note I said “older” named SQL queries. A recent update to Ignition added plain-text saving of SQL queries, but you have to open/close/save each at least once in Designer for them to be converted in the projects directory. I personally recommend going through all of the named queries and just touching them to trigger this conversion.

And, finally, this franken-command on Linux will let you grep the GZipped files in the project directory:

cd /usr/local/bin/ignition/data/projects
find . -type f -exec file {} \; | grep gz | awk -F ":" '{print $1}' | xargs -d "\n" zgrep ThingImGreppingFor

It doesn’t let you see the content of the match, but it gives good hints of what you might need to open in Designer.