﻿ NewBie's Corner Session 25 Globals and Arrays Part 1 | InterSystems
Article
· Sep 7, 2016 3m read

# NewBie's Corner Session 25 Globals and Arrays Part 1

NewBie's Corner Session 25 Globals, Variables, and Arrays Part 1

Welcome to NewBie's Corner, a weekly or biweekly post covering basic Caché Material.

Globals, Arrays, and Variables

A thorough understanding of Globals, Arrays, and Variables is foundational for every Caché developer.

A Global may be:

Scalar (a single element), as in a Global Variable

###### Example of an Global Array

The term "Global" is used to refer to either a Global Variable or a Global Array.

Parts of a Global (Array) Name

###### The data associated with the Global node

A Global (Array) may consists of a number of common elements or a number of non-common elements, as the term multidimensional (multi=many, dimensions) implies.

Example of a number of common elements

Example of a multidimensional array

In Caché, the term Global can be thought of as data stored on a computer disk. Global data is permanent or persistent, being stored on disk; it will not go away when the computer is shut down.

Persistent Variables and Arrays

A Global refers to persistent or permanent data, stored on disk, which may be variables or arrays.

Non–persistent Variables and Arrays

Variables and Arrays typically are non–persistent, that is, not stored on disk, but only stored in memory. These Variables and Arrays cease to exist when the computer shuts down or the process that created them ceases.

If it helps, you can think of Variables as "Local Variables", and Arrays as "Local Arrays", as opposed to "Global Variables" and "Global Arrays."

But bear in mind, when a developer refers to a Variable or Array, most likely they are referring to a Local Variable and Local Array. Otherwise, they will be called Global Variables and Global Arrays. Or just Globals, not making a distinction between variables or Arrays.

Global variables and arrays are handled just like local variables and arrays with the exception of the pre–ceding caret (^).

The only difference is that local variables and arrays exist only in memory, Global variables and arrays (their name being preceded by the caret (^) ) are persistent and exist on disk. They are only removed when explicitly killed.

To summarize:

###### –             Local Variables are One–Dimensional and not Persistent

Using the vernacular of other computer languages, Globals may be thought of as files. They reside on disk and are permanent, or persistent, until deleted. However, Globals are unique to Cache. They are not read in a sequential manner like traditional files. Be very careful when killing any Global. An entire database may be wiped out in an instant with one simple Kill command. Unfortunately, there is no warning that a Global is being deleted and no undelete capability. The Kill Global command may delete thousands or even millions of descendant nodes. The Kill is a powerful and dangerous command.