To exert more rigorous control, it can be helpful for many scripts to actively suppress the behavior of any script triggers that may be set off. This makes the behavior of a script more predictable, since triggered scripts would be known to have no effect while the main script is running. The main script could also disable and enable triggered scripts at will, selectively suppressing or taking advantage of triggered behaviors. This is accomplished with two scripting patterns and four custom functions.
Any script written to be called by a trigger should begin with an If  script step checking whether or not script triggers are currently being suppressed (after any header comments) using the TriggersAreActive custom function. That If  statement should contain all other steps within the script, so that, in effect, the script does nothing while triggers are suppressed.
Any script that may be disrupted by setting off script triggers can use Set Variable  script steps to invoke the TriggersDisable and TriggersEnable custom functions as needed. These two functions should always be used in pairs.