Top | Previous | Next |
About Scripting |
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. Python Scripting 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. 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:
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 Python 2.5. When looking at outside documentation, such as on www.python.org, verify that you are looking at the correct version of the documentation.
Expression Language The expression language is a simple language that we invented. An 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 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. |