Learn how to write scripts that run on startup of the Client or the Gateway.

Video recorded using: Ignition 7.7


(open in window)

[00:00] If you need to run some logic when your clients starts up or when the gateway is starting, you can use Startup Scripts. The Client Event Scripts has a Startup Script as does the Gateway Event Scripts. And of course, they run at very different times. So the Client Event Scripts version of the Startup Scripts will run every time a client is launched. This logic is run right after the login. So, right after the user logs successfully the Client Startup Script will run. Oftentimes we'll see people using this to open-up a custom set of windows, if maybe the opening set of windows should be different based on who logged in. The only thing to be really aware of for the Client Startup Script is that if you are trying to do something like logging back out or re-targeting, you should do that and then invoke later. For example, you will define what you wanted to do. Let's say under certain circumstances I wanted to log the user immediately back out. Here, I'm going to use but you can see I've put this call in a function definitions that I can use system.detail.invokelater. The reason to do this is because the Startup Script is run during the Client Startup it's better for the system to logout after all that startup stuff is finished. That's what invoke later does is it runs a function after the current event processing is finished. The Gateway Startup Script, of course, runs on the gateway and will run for each part that you have defined but it is important to remember that even though this script will run when the gateway first starts up, it may also run at additional times. For example, if you alter any of your Gateway Scopes Scripting or your Project Script Library, this script will get run again. So that every time any of the scripting for your project that affects the gateway changes, your project essentially restarts in the gateway. So, shut down and startup will be called. The reason this is required is that you may have made changes to scripts that this script references, so the dependencies of change, so you need to run it all again. It's really a Project Startup Script in the Gateway Scope rather than just a Gateway Startup Script. You need to remember that when you are writing this that this may run multiple times in the lifespan of a gateway.

You are editing this transcript.

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