SetGlobalVar

The SetGlobalVar function creates in a policy a global variable, which can be accessed from any local functions, library functions, and exception handlers in a policy.

The word global refers to the thread scope, which means that any policy code will access its own copy of the global variable from its own thread. Different threads that run the same policy will not interfere with one another, that is if the policy value is changed by one such running thread, the change does not affect the value of the global variable in other threads.

Syntax

SetGlobalVar(variablename, variablevalue)

Parameters

Table 1. SetGlobalVar function parameters

Parameter

Description

variablename

Name of the variable.

variablevalue

Initial value of the variable.

Example

This piece of code creates a global variable "MyAge" and sets its initial value to 33:

SetGlobalVar("MyAge", 33)

This piece of code clears the entry for the variable1 variable, by passing null value to SetGlobalVar() call:

SetGlobalVar(variable1, null)