| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Global triggers use the FreeM asynchronous event handling subsystem to allow a FreeM process to execute arbitrary M code when a particular action occurs on a particular global.
To set up a global trigger, you must set up an event handler for event class TRIGGER. The event identifier must be in the format of "<action>:<gvn>", where <gvn> is a global variable name, and <action> is one of the following:
DATATrigger will fire when the $DATA intrinsic function is called on <gvn>.
GETTrigger will fire when <gvn> is read from.
INCREMENTTrigger will fire when intrinsic function $INCREMENT is called on <gvn>.
KILLTrigger will fire when <gvn> is KILLed.
NEXTTrigger will fire when intrinsic function $NEXT is called on <gvn>.
ORDERTrigger will fire when intrinsic function $ORDER is called on <gvn>.
QUERYTrigger will fire when intrinsic function $QUERY is called on <gvn>.
SETTrigger will fire when SET <gvn>=value occurs.
ZDATATrigger will fire when intrinsic function ZDATA is called on <gvn>.
When a TRIGGER event occurs, the "GLOBAL" node of the ^$EVENT structured system variable will be populated with the global reference that invoked the trigger event.
If a SET or KILL trigger was the source of the TRIGGER event, the OLD_VALUE node of ^$EVENT will be populated with original value of ^$EVENT("GLOBAL") prior to the change, and NEW_VALUE will be populated with the new value. This allows triggers to contain logic to undo global changes. This functionality can also be used to provide auditing of specific global changes.
The following example shows a trigger implemented for SET operations on the ^DD global.
TRIGGER ;
;
; Set up a SET trigger on ^DD
;
SET ^$JOB($JOB,"EVENT","TRIGGER","SET:^DD")="ONSET^TRIGGER"
;
; Enable the TRIGGER event class
;
ASTART "TRIGGER"
;
; Try setting a node in ^DD
;
SET ^DD(1)="Test"
;
; Quit
;
QUIT
;
;
ONSET ;
WRITE "The "_^$EVENT("GLOBAL")_" global node was SET.",!
QUIT
You can also set up a trigger that applies to all FreeM processes by setting descendant subscripts of ^$SYSTEM("EVENT","TRIGGER",...) instead of using ^$JOB($JOB,"EVENT","TRIGGER",...).
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on May 19, 2025 using texi2html 5.0.