Wolfram Language & System 10.4 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

Ask

Ask["key"]
is a construct for use inside AskFunction that gives the value associated with key, or interactively asks for it if it is not already known.

Ask["key"formspec]
uses formspec to define how input should be requested and interpreted.

Ask[{"key1","key2",}]
gives the values associated with all the , interactively asking for any that are needed.

Ask[{"key1"->formspec1,"key2"->formspec2,}]
uses the to define how input for the should be requested and interpreted.

DetailsDetails

  • The first time Ask["key"] occurs in the evaluation of AskFunction[{,"key"->spec,},body], a value associated with is interactively requested using the form and interpretation specified by spec. Subsequent evaluations of Ask["key"] return the stored value.
  • Ask["key"] is taken to be equivalent to Ask["key"->"String"] if it is evaluated inside an AskFunction that does not give a specification for how to ask about .
  • Values found for using Ask["key"] can be changed through evaluation of subsequent AskAppend[] constructs and can be deleted through AskConfirm[].
  • If a specification for how to ask about a key is given in an AskFunction, it overrides any specifications given in Ask constructs it contains. If no specification is given in the AskFunction, then the specification in the first Ask to be evaluated is used.

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Ask for a number:

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

Collect a user's name and email:

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

Already known answers are not asked for again:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2016
(10.4)