$PreRead

$PreRead
is a global variable whose value, if set, is applied to the text or box form of every input expression before it is fed to Mathematica.

DetailsDetails

  • $PreRead is always applied to each complete input string that will be fed to Mathematica.
  • In multiline input with a text-based interface, whenever each line is terminated, $PreRead is typically applied to the input so far.
  • $PreRead is applied to all strings returned by a $SyntaxHandler function.
  • $PreRead is applied before InString[n] is assigned.

ExamplesExamplesopen allclose all

Basic Examples (3)Basic Examples (3)

By default, $PreRead is not defined, meaning input strings are sent directly to evaluation:

In[1]:=
Click for copyable input
Out[1]=

Use as an alias for HoldForm:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]//FullForm=

Restore $PreRead to its default value:

In[4]:=
Click for copyable input

Have Mathematica print the FullForm of parsed input expressions before evaluation:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=

Restore $PreRead to its default value:

New in 2
New to Mathematica? Find your learning path »
Have a question? Ask support »