Scripting in Ignition

Scripting is used in many places in Ignition to add a significant degree of flexibility and customization where pre-canned options fall short. There are two major scripting languages in Ignition, Python and the Expression Language. It is important to understand the differences between the two, and to know where each is used.

What is Python?

Most of the time when we talk about "scripting" we're talking about Python scripting. Python is a general purpose programming language that was developed in the early 90's and has gained significant popularity in the 2000's. We like it because it is extremely readable, elegant, powerful, and easy to learn. As an added bonus, it gracefully interacts with Java, giving programmers an extremely powerful tool when paired with Ignition, which is written in Java.

Since Python is such a popular and well-regarded language, there are many high-quality tutorials available on the web. The official Python tutorial, written by the inventor of Python himself, Guido van Rossum, is very good. https://docs.python.org/2/tutorial/index.html

Python or Jython?

You'll often hear Python referred to as "Jython" by advanced users of Ignition. Python is the language, Jython is the implementation of the language that we use. Most users of Python use the implementation called "CPython" - they just don't realize it. See http://en.wikipedia.org/wiki/Python_(programming_language)#Implementations.

Why not VBA?

Many HMI/SCADA packages use VBA, or Visual Basic for Applications. As such, many engineers switching to our software inquire about it. There are a variety of reasons we don't use VBA:

  • It is not compatible with Java, the language that Ignition is written in. This also means that it is not cross-platform.

  • It is a dying language (Microsoft has phased it out as of July, 2007).

  • It is full of security holes.

  • It is an ugly language!

Where is Python Used?

Python is used in many places in Ignition. The most apparent place is in component event handlers. Project event scripts are another major place where Python is used.

Which version of Python is Used?

Ignition uses Jython 2.5. Jython is the Python programming language implemented over the Java Virtual Machine. When looking at outside documentation, such as on www.python.org, verify that you are looking at the correct version of the documentation.

What is the Expression Language?

The Expression Language is a simple language that we invented and is different from the Python scripting. The expression language is a very simple kind of language where everything is an expression - which is a piece of code that returns a value. This means that there are no statements, and no variables, just operators, literals, and functions. The most common expression language that most people are familiar with is the one found in Microsoft Excel. You can have Excel calculated a cell's value dynamically by typing an expression like =SUM(C5:C10). Our expression language is similar. It is used to define dynamic values for tags and component properties. Expression language is most commonly used in expression bindings.

In this section ...