evaluates body, interactively asking for values specified by Ask[…] and related constructs.
specifies how values associated with the keyi should be asked for.
Details and Options
- The following special constructs can appear in the body of an AskFunction:
Ask[…] ask for the value of a key if not already known AskedValue[…] get the value of a key if it is known AskAppend[…] ask for a value and append it to the list of known values AskConfirm[…] confirm or change a value AskDisplay[…] display an expression with asked values inserted AskTemplateDisplay[…] display a template applied to the asked values AskedQ[…] test if the value of a key has been asked for
- AskFunction[…] evaluates in a notebook, displaying a form every time it encounters a construct that requires asking for a value.
- CloudDeploy[AskFunction[…]] yields a CloudObject corresponding to an active version of the AskFunction.
- AskFunction[…][<|"keyk"->inputk|>] represents an AskFunction where the value associated with "keyk" is taken to be inputk.
Examplesopen allclose all
Basic Examples (1)
Set up an AskFunction:
Activate it and fill in the inputs:
You can programmatically provide known values:
Provide a first argument to AskFunction to specify how to ask for values:
AskFunction uses the evaluation semantics of the Wolfram Language to skip the questions that are not needed:
Selecting No skips the question about the spouse name:
Use the same syntax as FormFunction and FormObject to specify the appearance of the questions:
Properties & Relations (7)
Use AskFunction in conjunction with Ask for simple questions or to get the value associated with a key:
AskConfirm can be used to rewind the evaluation to the point before a value was known:
Use AskAppend to accumulate inputs:
Use AskDisplay to display messages:
AskTemplateDisplay takes a function or a template to be applied to the current values:
Use AskedQ to verify if a key has been asked:
AskedValue returns the value without causing a form to be displayed:
Possible Issues (1)
When AskFunction is deployed in the cloud, the body is reevaluated at each visit on a clean kernel. Because of this, functions that return random values might return different values at each step:
A possible workaround is using SeedRandom to initialize the pseudorandom number generator with a seed that depends on previous values or on values such as $RequesterAddress:
Wolfram Research (2016), AskFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/AskFunction.html.
Wolfram Language. 2016. "AskFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/AskFunction.html.
Wolfram Language. (2016). AskFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AskFunction.html