Skip to content

Libraries

A library is a script whose trigger is Library: it never runs by itself. It is there to be imported by other scripts.

That is how a script that grew too big gets split up. The bulky part moves into a library with a page, an editor and a dry run of its own — instead of living on as a thousand lines nobody dares touch.

In the tree on the left, New offers New library. It gets a path like any script, for example Plant1.Conversion. It is imported by exactly that path:

import Plant1.Conversion
from Plant1.Conversion import to_pascal

Inside a library, system. is there just as in the script that imports it — system.tag.write, system.file.list, system.log.info — so an importer can live in one library and be started from two scripts, one on File arrived and one behind a button.

A library’s page has no Run now and no run log. Both would be a promise that cannot be kept: the server refuses an attempt to start it. In their place stands Who uses it.

That is the only question anybody actually has about a library — and the one that has to be answered before deleting or renaming it. The list names the paths of the scripts that import this library; a click jumps there.

It is worked out by reading the code. The usual forms are recognised:

import Plant1.Conversion
import Plant1.Conversion as u
from Plant1.Conversion import to_pascal
from Plant1 import Conversion

What is not recognised: an import assembled at run time, such as importlib.import_module(name). The list is therefore a hint for a person, not a guarantee. It is not the tags’ binding graph either: an import is about code, not about values.

An import names the path inside the other scripts’ own code. Move or delete the library and nobody finds it under the old name — and TrakState does not rewrite somebody else’s code.

So both are refused while other scripts import it. You get the list and the question: Move anyway or Delete anyway. The second click is the one that breaks the imports; afterwards you have to follow them up by hand.

A folder can be renamed with everything under it in one go. The same check applies there.

The Problems tab says Not found here: … when an import names neither a script of this tenant nor a module Python is known to bring along. Two harmless cases look exactly the same: a library that does not exist yet, and a Python package installed on this plant that TrakState knows nothing about. Which is why this is a hint and not an error.