Where Is Scripting Used?
Python is used in many places in Ignition. Each location has it's own events that trigger your scripts to run, and add functionality to your projects in different ways. The most apparent place is in event handlers on components and other objects in Ignition Clients. Project and Gateway event scripts are another major place where Python is used.
Script Scope
One important thing to keep in mind before scripting in Ignition, is to understand the concept of scope. Within Ignition, there are two different scopes: the Gateway Scope and the Client Scope. Where a script is run from determines what scope it is running in. This is important because it determines what system functions can be run, what resources the script can interact with, and where the output will be written to. For example, running a script on a Tag is run in the Gateway Scope and the output is sent to the Gateway console (i.e., wrapper.log file) because Tags are stored in the Gateway. This means that the script will not be able to access any client level resources such as windows or components that you may have open in the Client. Additionally, some of the system functions like system.gui.errorBox() only work in the "Client Scope," so you will not be able to use them in the script on the Tag.
"Client Scope" scripts, however, execute on the running client (and also in Designer when testing, but only in Preview Mode). For example, if a component on a window is running a script, its values are isolated to the client, and the output will be displayed on the Designer/Client output console.
System Functions
Ignition comes with a group of system functions, called the System Library. Using a system function is simple. For example, the following code will access the value of a Tag.
value = system.tag.read("tagPath").value
A complete list of these functions (with their definitions) is available wherever you can add a script. Just type system. and then press Ctrl+Space to get a list of all the functions available. If you keep typing, the list will even be automatically narrowed down for you! Additionally, the Scripting Functions page in the appendix contains complete documentation for the built-in system functions.
