2
$\begingroup$

Consider some input field:

number = 
 DialogInput[{number = ""}, 
  Column[{"Enter the number", InputField[Dynamic[number], Number], 
    Button["Proceed", DialogReturn[number], ImageSize -> Automatic]}]]

It is not possible to enter any non-numeric symbol like * or ^. In particular, it is not possible to enter large numbers, e.g. 2*10^20, or 2e20. Could you please tell me how to change DialogInput to allow such numbers?

One option would be change Number to String, and later add ToExpression. But it seems to me that it is not optimal, and potentially may lead to bugs.

$\endgroup$

1 Answer 1

3
$\begingroup$

You may use the default type of "Expression" for the input field. To eliminate the empty string in the input field, you can set the initial value to: Null.

Here is an example:

number =

 DialogInput[{number = Null}, 
  Column[{"Enter the number", InputField[Dynamic[number]], 
    Button["Proceed", DialogReturn[number], ImageSize -> Automatic]}]]

enter image description here

Now with some input:

![enter image description here

200 \[Pi]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.