This lesson is part of the Scripting in Ignition course. You can browse the rest of the lessons below.

LESSON LIST

Autoplay Off
Take topic challenge

Supplemental Videos

LESSON

Scripting Scope

Description

Learn about different domains for Ignition scripting and how different code works when run in different places.

Video recorded using: Ignition 8.0

Transcript

(open in window)

[00:00] Script scope is an important part of scripting in Ignition. The scope of a script is determined by where it is being executed. This is important. As it determines which functions the script is able to run. As well as what the script is able to access. For example, here within my vision window I have placed a button. The button is calling a very simple function. The system.gui.message box function. That simply opens up a message box to the user. If I put my designer into preview mode and then click on my button, the message box appears. This is known as the client scope. And it allows the script to interact with the client and the computer that the client is running on. This differs from the gateway scope. The gateway scope can be found on Tag Event Scripts or Gateway Event Scripts. In the gateway scope, the script executes on the gateway. This means that the script has access to the gateway computer. As well as only being able to run gateway scoped functions. My previous example of the message box function won't work here in the gateway scope. Because there's no interface to display the message box on. When dealing with the new visualization system perspective the scope is a little unique. When running a script in a perspective session the scripts are executed on the gateway. This means that like our gateway scope we don't have access to things like the message box function. However, when running a script in perspective you do have access to some special scripting functions. You can see here that I'm using one of them. System.perspective.refresh. When run inside of a page in a perspective session it will simply refresh the session by telling the web browser to refresh that web page. If I go into my session that I have open now. And I click on that button, you can see that it refreshes the web page. When creating scripts within Ignition, it is important to keep these scopes in mind. As they may effect what you can do within your script.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.