Tools for EventScripter

System function: global()

Description

global(string key [, object value]) : object

Gets or sets a global session variable for all current running scripts. It's a short combined version of getProperty(key, true) and setProperty(key, value, true).

Example

// Trigger Required: "Interval"
// Options recommended: 1000ms, synchronous

require(JD_HOME + "/eventscripter/system/global.js");

var counter = global("counter") || 0;
counter += 1;
alert(counter);
global("counter", counter);

Sourcecode

JD_HOME/eventscripter/system/global.js
/*jslint browser */
/*global getProperty, setProperty */
function global(k, v) {
    "use strict";

    return (
        (v === undefined)
        ? (getProperty(k, true) || null)
        : setProperty(k, v, true)
    );
}