({{, (RefLink[Dialog, paclet:ref/Dialog])[]
initiates a dialog. }, {, (RefLink[Dialog, paclet:ref/Dialog])[expr]
initiates a dialog with expr as the current value of %. }})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[Dialog, paclet:ref/Dialog]) creates a dialog that consists of a sequence of input and output lines.

You can exit a dialog using (RefLink[Return, paclet:ref/Return]).

With the global setting (RefLink[$IgnoreEOF, paclet:ref/$IgnoreEOF])=(RefLink[False, paclet:ref/False]), you can also exit a dialog by entering an end-of-file character.

If you exit with (RefLink[Return, paclet:ref/Return])[expr], then expr is the value returned by the (RefLink[Dialog, paclet:ref/Dialog]) function. Otherwise, the value returned is the expression on the last output line in the dialog.

(RefLink[Dialog, paclet:ref/Dialog]) automatically localizes the values of (RefLink[$Line, paclet:ref/$Line]), (RefLink[$MessageList, paclet:ref/$MessageList]), and (RefLink[$Epilog, paclet:ref/$Epilog]).

(RefLink[Dialog, paclet:ref/Dialog]) initially sets the local value of (RefLink[$Line, paclet:ref/$Line]) to be equal to its global value. This means that the numbering of input and output lines in the dialog follows the sequence outside the dialog. When the dialog is exited, however, the numbering reverts to the sequence that would be followed if there had been no dialog.

Any local value assigned to (RefLink[$Epilog, paclet:ref/$Epilog]) is evaluated when the dialog is exited.

The main loop within a dialog uses global variables such as (RefLink[$Pre, paclet:ref/$Pre]) and (RefLink[$Post, paclet:ref/$Post]).

The option (RefLink[DialogSymbols, paclet:ref/DialogSymbols]):>{x,y,…} sets up local values for variables within the dialog. (RefLink[DialogSymbols, paclet:ref/DialogSymbols]):>{x=(Subscript[x, 0]),…} defines initial values for the variables.

The option (RefLink[DialogProlog, paclet:ref/DialogProlog]):>expr specifies an expression to evaluate before starting the dialog.

(RefLink[Dialog, paclet:ref/Dialog]) first localizes variables, then evaluates any expression specified by (RefLink[DialogProlog, paclet:ref/DialogProlog]), then evaluates any argument you have given for (RefLink[Dialog, paclet:ref/Dialog]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (2)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

To evaluate this expression, the Wolfram System initiates a dialog:

1+Dialog[]^2

Computations can be done within the dialog just like an ordinary Wolfram System session:

s = Sin[t] + Cos[t];

Return from the dialog. The value is inserted in the original expression to get (RefLink[Out, paclet:ref/Out])[1]:

Return[s+t^2]

OpenersExampleSection1(Spacer1)Scope  (1)

Run a dialog each time through a loop:

x = 1;Do[x *= Dialog[],{i,3}]

You can see the current value of the loop variable i in the dialog:

i

Return from the first dialog. x is multiplied by the current value of i:

Return[i]

The current values of i and x:

{i,x}

Return from the second dialog. x is multiplied by the current value of i squared:

Return[i^2]

Return from the third dialog:

Return[i^3]

The value of x after the loop:

x

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[TraceDialog, paclet:ref/TraceDialog])  ▪  (RefLink[Input, paclet:ref/Input])  ▪  (RefLink[$Inspector, paclet:ref/$Inspector])  ▪  (RefLink[Return, paclet:ref/Return])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Dialogs, paclet:tutorial/Dialogs])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Flow Control, paclet:guide/FlowControl])}, {▪(RefLinkPlain[Tuning & Debugging, paclet:guide/TuningAndDebugging])}, {▪(RefLinkPlain[Tokens Related to the Evaluation Menu, paclet:guide/EvaluationTokens])}})}})