({{, (RefLink[InString, paclet:ref/InString])[n]
is a global object that is assigned to be the text of the n(^th) input line. }})

OpenersNotesSection(Spacer1)Details

(RefLink[InString, paclet:ref/InString])[n] gives the string that the Wolfram Language read for the n(^th) input line. In a text-based interface, the string includes all intermediate newlines in the input, but not the newline at the end.

In a notebook interface, (RefLink[InString, paclet:ref/InString]) will typically return a string representing a typeset expression.

The value of (RefLink[InString, paclet:ref/InString])[n] is assigned after the input is verified to be syntactically correct, and after any function given as the value of (RefLink[$PreRead, paclet:ref/$PreRead]) has been applied.

(RefLink[InString, paclet:ref/InString])[] gives the text of the last input line.

(RefLink[InString, paclet:ref/InString])[-k] gives the text of the input k lines back.

OpenersPrimaryExamplesSection(Spacer1)Examples  (3)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Show input as a string:

a=1.;a = a/2+1/a

With (RefLink[StandardForm, paclet:ref/StandardForm]) input, the string represents a typeset expression:

InString[]

OpenersExampleSection1(Spacer1)Scope  (1)

Create three inputs:

a;
b;
c;

Retrieve the first input string:

InString[1]

Get the next-to-last input string:

InString[-2]

OpenersExampleSection2(Spacer1)Properties & Relations  (1)

(RefLink[InString, paclet:ref/InString]) returns a string:

a b

InString[] //InputForm

In (RefLink[StandardForm, paclet:ref/StandardForm]), calling (RefLink[ToExpression, paclet:ref/ToExpression]) on the result will return a typeset expression:

ToExpression[%]//InputForm

(RefLink[MakeExpression, paclet:ref/MakeExpression]) converts the typeset expression to the input expression:

MakeExpression[%,StandardForm]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[In, paclet:ref/In])  ▪  (RefLink[$SyntaxHandler, paclet:ref/$SyntaxHandler])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Using a Text-Based Interface, paclet:tutorial/UsingATextBasedInterface])}, {▪(RefLinkPlain[Doing Computations in Notebooks, paclet:tutorial/DoingComputationsInNotebooks])}, {▪(RefLinkPlain[The Main Loop, paclet:tutorial/TheMainLoop])}, {▪(RefLinkPlain[Wolfram System Sessions, paclet:tutorial/WolframSystemSessions])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Wolfram System Session History, paclet:guide/WolframSystemSessionHistory])}})}})