Global System Information

In order to write the most general Wolfram Language programs you will sometimes need to find out global information about the setup under which your program is being run.

Thus, for example, to tell whether your program should be calling functions like (RefLink[NotebookWrite, paclet:ref/NotebookWrite]), you need to find out whether the program is being run in a Wolfram Language session that is using the notebook front end. You can do this by testing the global variable (RefLink[$Notebooks, paclet:ref/$Notebooks]).

Determining whether a notebook front end is being used.

The Wolfram System is usually used interactively, but it can also operate in a batch mode—say taking input from a file and writing output to a file. In such a case, a program cannot for example expect to get interactive input from the user.

Variables specifying batch mode operation.

The Wolfram Language kernel is a process that runs under the operating system on your computer. Within the Wolfram Language there are several global variables that allow you to find the characteristics of this process and its environment.

Variables associated with the Wolfram Language kernel process.

If you have a variable such as x in a particular Wolfram Language session, you may or may not want that variable to be the same as an x in another Wolfram Language session. In order to make it possible to maintain distinct objects in different sessions, the Wolfram Language supports the variable (RefLink[$SessionID, paclet:ref/$SessionID]), which uses information such as starting time, process ID and machine ID to try to give a different value for every single Wolfram Language session, whether it is run on the same computer or a different one.

A unique number different for every Wolfram Language session.

The Wolfram Language provides various global variables that allow you to tell which version of the kernel you are running. This is important if you write programs that make use of features that are, say, new in Version 6. You can then check (RefLink[$VersionNumber, paclet:ref/$VersionNumber]) to find out if these features will be available.

Variables specifying the version of the Wolfram System used.

The Wolfram System itself is set up to be as independent of the details of the particular computer system on which it is run as possible. However, if you want to access external aspects of your computer system, then you will often need to find out its characteristics.

Variables specifying the characteristics of your computer system.

The Wolfram System uses the values of (RefLink[$SystemID, paclet:ref/$SystemID]) to label directories that contain versions of files for different computer systems, as discussed in "Reading and Writing Wolfram Language Files: Files and Streams" and "Portability of WSTP Programs". Computer systems for which (RefLink[$SystemID, paclet:ref/$SystemID]) is the same will normally be binary compatible.

(RefLink[$OperatingSystem, paclet:ref/$OperatingSystem]) has values such as "Windows" or "Unix". By testing (RefLink[$OperatingSystem, paclet:ref/$OperatingSystem]) you can determine whether a particular external program is likely to be available on your computer system.

This gives some characteristics of the computer system on which the input is evaluated:

{$System,$ProcessorType,$OperatingSystem}

Variables identifying the computer on which the Wolfram System is running.

Variables associated with license management.