$R[EFERENCE] contains the last global reference. Until the first global reference is made by an M program, $REFERENCE contains the empty string (""). This way it is useful in determining if the usage of a naked reference is valid.

A typical way of using this is:

IF $REFERENCE="" QUIT "<undefined>"
[Note] Note

$R[EFERENCE] being a read-only variable cannot be SET or NEW'd.