Is it possible to create a script in "Scripting/Script Project" and call it from some kind of perspective component? Scripting is a paid module?
On the other hand, could I create custom libraries on the Ignition installation site and call them from perspective?
Yes, standard functionality. Simply create functions in script modules in your project's scripting library. You won't even have to use jython's import
to use them.
Only for pure gateway scope on Ignition Edge (you would buy the "compute" plugin). It is a standard part of the platform for all other editions and scopes.
Yes, you can create pythonish "Site Packages" under the normal hierarchy in the Ignition install folder. For these you will need to use import
.
Excellent! And could you give me an example of how to call a function in any component?
I have this little test script and I would like it to return the message in the "text" property of a label.
Or any other example of how to call this type of script in a component would be very helpful! thank you...
In a component binding, use an expression binding with the runScript() expression function. Something like this:
runScript("hi.buenIntento", 0)
or this:
runScript("hi.hola", 0, {path.to.some.prop.for.hi})
From an event script, you'd just call them by their full name as normal jython functions.
That you are asking such simple questions about Ignition suggests that you haven't used IA's free online training: Inductive University. Going through it will save you some grief, and may help you avoid reworking your designs.
You can call functions in the 2 ways described by Phil: runscript
in expression, and regular function calls in jython.
What he didn't say is that there are several places where you can use jython:
- script transforms in bindings
- value change scripts on properties
- components custom methods and message handlers
- components extension functions
- tag change scripts
- gateway events
- session events
As he said, go through the university, it will teach you the basics, so that you have some ground to stand on when learning all the cool parts of ignition.