This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Documentation / Mathematica / The Mathematica Book / Principles of Mathematica / Global Aspects of Mathematica Sessions /

2.14.5 Advanced Topic: Global System Information

In order to write the most general Mathematica 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 NotebookWrite, you need to find out whether the program is being run in a Mathematica session that is using the notebook front end. You can do this by testing the global variable $Notebooks.

Determining whether a notebook front end is being used.

Mathematica 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 Mathematica kernel is a process that runs under the operating system on your computer. Within Mathematica there are several global variables that allow you to find the characteristics of this process and its environment.

Variables associated with the Mathematica kernel process.

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

A unique number different for every Mathematica session.

Mathematica 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 5. You can then check $VersionNumber to find out if these features will be available.

Variables specifying the version of Mathematica used.

Mathematica 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.

Mathematica uses the values of $SystemID to label directories that contain versions of files for different computer systems, as discussed in Sections 2.12.1 and 2.13.5. Computer systems for which $SystemID is the same will normally be binary compatible.

$OperatingSystem has values such as "Unix" and "MacOS". By testing $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 used to generate the examples for this book.

In[1]:= {$System, $ProcessorType, $OperatingSystem}

Out[1]=

Variables identifying the computer on which Mathematica is running.

Variables associated with license management.