Skip to main content

Special Variables

Special Variables

ObjectScript includes special variables (also referred to as system variables) that are used to make certain system information available to applications. All special variables are supplied with InterSystems IRIS and are named with a $ character prefix. Users cannot define additional special variables. The special variables are available in all namespaces.

The value of a special variable is set to the current state of some aspect of your operating environment. Some special variables are initially set to the null string (""); referencing a special variable should never generate an <UNDEFINED> error. The value of a special variable is specific to the current process and cannot be accessed from another process.

Users can set some special variables with the SET command; other special variables are not user-modifiable. Refer to the individual special variables for further details.

The following example uses the special variable $HOROLOG:

 SET starttime = $HOROLOG
 HANG 5
 WRITE !,$ZDATETIME(starttime)
 WRITE !,$ZDATETIME($HOROLOG)

The special variable $HOROLOG stores the current system date and time. The SET command uses this special variable to set the user-defined local variable starttime to this value. The HANG command then suspends the program for 5 seconds. Finally, the two $ZDATETIME functions return starttime and the current system date and time in a user-readable format.

Other examples of special variables include:

 WRITE !,"$JOB = ",$JOB   // Current process ID
 WRITE !,"$ZVERSION = ",$ZVERSION   // Version info

Many special variables are read-only; they cannot be set using the SET command. Other special variables, such as $DEVICE, are read-write, and can be set using the SET command.

Special variables cannot take subscripts. Special variables cannot be incremented using the $INCREMENT function or killed using the KILL command. Special variables can be displayed using the WRITE, ZWRITE, ZZWRITE, or ZZDUMP commands, as described in Display (Write) Commands.

Refer to the ObjectScript Reference for a list and detailed descriptions of the special variables.

FeedbackOpens in a new tab