Chat now with support
Chat with Support

InTrust 11.3.1 - Customization Kit

GlobalState

The GlobalState object is similar to the ScriptState object, but with the following differences:

  • It is available only in JScript.

  • It stores the state of the object only as long as the agent process is active.

  • It can store objects of any type.

Example

if ( !GlobalState.Item("shell") )
  {
    GlobalState.Item("shell") = new ActiveXObject("WScript.Shell");
  }
#TRACE 40 GlobalState.Item("shell").Value.ExpandEnvironmentStrings("%TMP%")

Position

Creatable.

NAME

TYPE

DESCRIPTION

RecordKey

property

Has integral type

Time

property

Has Date type

Values

property

Collection of user-supplied properties

Example

x = new Position;
x.RecordKey = 12;
x.Time = new Date();
x.Values.prop1 = "val1";
x.Values.prop2 = new Date();

Reference

The Reference object is a wrapper used mainly for passing the out parameter to COM methods. To create a call, use the function CreateReference(value) where value is an optional argument that specifies the start value. This object is available when you use the ECMAScript or JScript object model.

You cannot correctly reference a property if at least one of its parameters is [in, out].

IDL example

HRESULT Increment([in, out] LONG * param);

JScript example

var ref = CreateReference(5);
var obj = new ActiveXObject("MyObject");
obj.Increment(ref);
x = ref; // x = 6;
ECMAScript example:
var ref = CreateReference(5);
var obj = new ActiveXObject("MyObject");
DispInvoke(obj, "Increment", ref);
x = ref.RefOn; // x = 6;

ScriptState

ScriptState is an object with arbitrary fields that stores values between calls and between InTrust agent restarts. This object is available when you use the ECMAScript or JScript object model.

The ScriptState object can store only the following data types:

  • Strings

  • Numeric types

  • Dates

  • Arrays of all of the above

GlobalState is a similar object that can store any data type, but is available only in the JScript object model.

In the following two examples, every fifth event is matched.

ECMAScript Example

function OnEvent( e )
{
  if (ScriptState.count == 5 )
    {
      match( e );
      ScriptState.count = 0;
    }
  else
    {
      ScriptState.count++;
    }
}

JScript Example

function OnEvent( e )
{
  if (ScriptState.Item("count") == 5 )
    {
       match( e );
       ScriptState.Item("count") = 0;
    }
  else
    {
      ScriptState.Item("count")++;
    }
}

Related Documents