RunGlobalProcedureOnTrigger
This function runs a global procedure when the value or quality of a specified tag changes.
Function | Group | Execution | Windows | Embedded | Thin Client | Mobile Access |
---|---|---|---|---|---|---|
RunGlobalProcedureOnTrigger | Module Activity | Synchronous | Supported | Supported | Supported | Not supported |
Syntax
RunGlobalProcedureOnTrigger("strTagName",strProcedureOnTrigger)
- strTagName
- The name of a project tag.
Note: The tag name should be enclosed in quotes, as shown in the syntax diagram, or else the function will try to use the value of the tag.
- strProcedureOnTrigger
- The name of the procedure (i.e., a VBScript function or sub-routine defined in the Procedures folder of your project) to run when the value or quality of the specified tag changes.
Returned value
Value | Description |
---|---|
0 | Error |
1 | Success |
Notes
Once this function is called, it is continuously executed by the project runtime client (i.e., the Viewer) until either it or the project runtime server is stopped. That means every time the value or quality of the specified tag changes, the procedure is run. Also, the function can be called more than once, so that the same procedure can be run by different triggers. The project runtime client manages the execution of all instances of the function.
Sub MyProcedure(strTrigger) . . . End Sub
strTrigger = $tagname->Value
…or…
strTrigger = $tagname->Quality
…depending on which one changed. You can then use the value or quality in your procedure.
Please note that you do not actually have to use the argument, only that you should write the procedure to receive it.
No other arguments can be passed to the procedure.
[Options] EnableTagNameOnRunGlobalProcedureOnTag=<0 (disabled) / 1 (enabled)>
Examples
RunGlobalProcedureOnTrigger("MyInteger","MyProcedure")
The equivalent of MyInteger->Value or MyInteger->Quality, depending on which one changed, is passed to the procedure as an argument.