Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRISOpens in a new window, see the InterSystems IRIS Migration Guide and Migrating to InterSystems IRIS, both available on the WRC Distributions pageOpens in a new window (login required).

Globals

In Caché, the term global has a different meaning than in other languages. In other languages, a global variable is global to multiple subroutines and functions in a module. In Caché, a global variable is global to all processes, because its stored on disk. Here's a summary so that you can keep things clear:

Term Meaning Scope Example
Global A persistent array, on disk All Basic processes have access to the disk, and all routines in those processes can access this global. ^A
Process Private Global A persistent array, on disk Even though this is a global, only routines that run in your process can access this variable. It acts like a module-level variable that can grow in size beyond the limits of process memory. ^||A
Module-level (global) variable A variable defined in a Basic routine, outside of subroutines and functions Subroutines and functions in the module can access this variable. A
Private (local) variable A variable defined in a subroutine or function Only the subroutine or function that defines the variable can access it. A

It's very easy to learn about globals in Basic. Everything you just learned about arrays applies to globals. You don't have to declare them. When you're ready to store something on disk, just use assignment statements—using the “^” as part of the global name—and you'll build a tree on disk just like the one you saw in the animation. Space on disk is only used when it's needed. The three Erase* functions erase parts or sections of globals, including an entire global—even with a million records!—immediately. Nearly all the functions and commands that you've learned about using regular variables work on globals in the exact same way. The only difference is the use of the “^” (caret) or “^||” character(s) before the global name.

FeedbackOpens in a new window