Skip to main content

Formal Rules about Globals

This topic describes formal rules governing globals and global references (apart from extended global references, discussed separately).

Introduction to Global Names and Limits

The basic rules for global names are as follows:

  • The name begins with a caret character (^) prefix. This caret distinguishes a global from a local variable.

  • The next character can be a letter or the percent character (%):

    • Globals with names that start ^% are available in all namespaces. These are sometimes called percent globals.

    • Globals with names that do not use % are available only in the current namespace unless there are global mappings in effect.

  • The other characters of a global name may be letters, numbers, or the period (.) character, except that the last character of the name cannot be a period.

  • A global name may be up to 31 characters long (exclusive of the caret character prefix). You can specify global names that are significantly longer, but InterSystems IRIS treats only the first 31 characters as significant.

  • Global names are case-sensitive.

  • There are naming conventions to follow to avoid collision with InterSystems globals; see Global Variable Names to Avoid.

  • InterSystems IRIS imposes a limit on the total length of a global reference, and this limit, in turn, imposes limits on the length of any subscript values. See Maximum Length of a Global Reference.

For more details, see Rules and Guidelines for Identifiers.

Variations

  • A process-private global is an array variable that is only accessible to the process that created it. The name of a process-private global starts with ^|| rather than a single caret (^). For details, see Process-Private Globals.

  • You can refer to a global in another namespace via an extended global reference.

Introduction to Global Nodes and Subscripts

A global typically has multiple nodes, generally identified by a subscript or set of subscripts. For a basic example:

 set ^Demo(1)="Cleopatra"

This statement refers to the global node ^Demo(1), which is a node within the ^Demo global. This node is identified by one subscript.

For another example:

 set ^Demo("subscript1","subscript2","subscript3")=12

This statement refers to the global node ^Demo("subscript1","subscript2","subscript3"), which is another node within the same global. This node is identified by three subscripts.

For yet another example:

 set ^Demo="hello world"

This statement refers to the global node ^Demo, which does not use any subscripts.

The nodes of a global form a hierarchical structure. ObjectScript provides commands that take advantage of this structure. You can, for example, remove a node or remove a node and all its children; see Using Multidimensional Storage (Globals).

Important:

Note that any global node cannot contain a string longer than the string length limit, which is extremely long. See General System Limits.

Rules for Global Subscripts

Subscripts have the following rules:

  • Subscript values are case-sensitive.

  • A subscript value can be any ObjectScript expression, provided that the expression does not evaluate to the null string ("").

    The value can include characters of all types, including blank spaces, non-printing characters, and Unicode characters. (Note that non-printing characters are less practical in subscript values.)

  • Before resolving a global reference, InterSystems IRIS evaluates each subscript in the same way it evaluates any other expression. In the following example, we set one node of the ^Demo global, and then we refer to that node in several equivalent ways:

    SAMPLES>s ^Demo(1+2+3)="a value"
     
    SAMPLES>w ^Demo(3+3)
    a value
    
    SAMPLES>w ^Demo(03+03)
    a value
    
    SAMPLES>w ^Demo(03.0+03.0)
    a value
    
    SAMPLES>set x=6
     
    SAMPLES>w ^Demo(x)
    a value
    
  • InterSystems IRIS imposes a limit on the total length of a global reference, and this limit, in turn, imposes limits on the length of any subscript values. See Maximum Length of a Global Reference.

Caution:

The preceding rules apply for all InterSystems IRIS supported collations. For older collations still in use for compatibility reasons, such as “pre-ISM-6.1”, the rules for subscripts are more restrictive. For example, character subscripts cannot have a control character as their initial character; and there are limitations on the number of digits that can be used in integer subscripts.

Collation of Globals

Within a global, nodes are stored in a collated (sorted) order.

Applications typically control the order in which nodes are sorted by applying a conversion to values used as subscripts. For example, the SQL engine, when creating an index on string values, converts all string values to uppercase letters and prepends a space character to make sure that the index is both not case-sensitive and collates as text (even if numeric values are stored as strings).

FeedbackOpens in a new tab