0
$\begingroup$

Writing:

DialogInput[DialogNotebook[
  {TextCell["(" <> ToString[Subscript["m", "2"], StandardForm] <> ")"],
   InputField[Dynamic[x], String],
   DefaultButton[DialogReturn[x]]}]]

I get:

enter image description here

and I do not understand how to correct the code.

$\endgroup$
  • 2
    $\begingroup$ ExpressionCell[..., ShowStringCharacters -> False] $\endgroup$ – Kuba Mar 8 '18 at 9:31
  • $\begingroup$ Perfect, thank you very much! :) $\endgroup$ – TeM Mar 8 '18 at 16:20
2
$\begingroup$

I would avoid linear syntax (strings generated using ToString[.., StandardForm]) and just use normal expressions. For example:

DialogInput[
    DialogNotebook[
        {
        Row[{"(", Subscript[m, 2], ")"}],
        InputField[Dynamic[x],String],
        DefaultButton[DialogReturn[x]]
        }
    ],
    ShowStringCharacters->False
]
$\endgroup$
  • $\begingroup$ Really very useful! I have used this strategy in the whole program I am writing, it eliminates a lot of problems that creates ToString. :) $\endgroup$ – TeM Mar 9 '18 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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