Using system.db.refresh() to update connection to a global script

I am trying to figure out how to use system.db.refresh() in a project in order to refresh the binding to our "LabelPrintRack" shared (global) script below. There are changes made to this script that I need to utilize in this project but I can't figure out how to refresh this connection. This is on a simple button-push event in the current project that feeds some parameters into the mentioned LabelPrintRack script.

Does anyone know if this is the right method to refresh this script connection? If so how exactly should the arguments look for this? Thanks for the help and sorry if this is a dumb question.

image

https://docs.inductiveautomation.com/display/DOC80/system.db.refresh

System.db.refresh is for refreshing a SQL Binding on a JComponent, a vision component.

What exactly is the issue you are running into you need to resolve?

I have a project that is used for label printing that calls the LabelPrintRack function via inheritance. Let's say this project is called "PrintProject" and the global one is just called "Global." Global has the LabelPrintRack script that I need to call and use inside PrintProject.

But after updating the LabelPrintRack function in Global and saving that project, I have opened the other project PrintProject to find it is still "looking at" at the previous version of Global. So the updates I have made are not seen and thus I am running into a roadblock...

In your code in LabelPrintRack, are you using import to pull in the functions from Global? If so, don't. Just use the fully-qualified name of functions in Global anywhere else you need them. (You should never import a project library script. Only use import with java classes and jython site-packages.)

3 Likes

Nope, doesn't look like that is how it is set up. I am working with a legacy Ignition MES made by someone who is no longer around, so I'm always open to ways to do things better.

Can I ask why that is bad practice? Just so I can understand things a bit better

When you import a project script, it'll bring a copy of the Python code into the local script as it was at the time of import, which can cause all kinds of fun:

I tend to use this to avoid very long and ugly looking full path, particularly if it's a function I'm using a lot:

func = some_module/and_some_folder/some_script.func_from_far_away

bad idea ?

At the outermost level of the script? Yes, it's a bad idea. It is effectively an import because it persists for the life of the library script.

Nested in a function that will execute and go out of scope relatively quickly? (This assignment itself, not just usage.) Not a problem.