5
$\begingroup$

Bug introduced in 8 or earlier and fixed in 9


What is going on here?

Print[InputField[]]
CellPrint[TextCell["my\"text", "Text", ShowStringCharacters -> True]]

enter image description here

If I insert the above code into a blank notebook and run it, only the second cell seems to appear. If I run the code a 2nd time, both Cells are displayed.

How do I correct the code, so the InputField will be displayed the 1st time the code is run?

I am running Mathematica 8 on Windows 7.

$\endgroup$
  • 2
    $\begingroup$ I can not reproduce your problem. I see both the input field and the string 'my"text' on the first evaluation. (V9.0.1 on OS X 10.6.8) $\endgroup$ – m_goldberg Jun 18 '13 at 6:09
  • $\begingroup$ Can anyone confirm the issue in M8? @m_goldberg This is what I get if I run it a second time i.stack.imgur.com/Lt9EY.png $\endgroup$ – William Jun 18 '13 at 6:16
  • $\begingroup$ What your link show is what I see on the first evaluation. $\endgroup$ – m_goldberg Jun 18 '13 at 6:18
  • 1
    $\begingroup$ I can reproduce the problem with v8 on Windows 7. A workaround is to add a tiny pause between the two lines, e.g. Print[InputField[]];Pause[0.0001];CellPrint[blah...] $\endgroup$ – Simon Woods Jun 18 '13 at 8:50
  • 1
    $\begingroup$ I also reproduce the problem with version 8.0.4 on Windows 7 x64. The problem doesn't appear with versions 9.0.1, 10.0.1 and 11.2.0 on the same machine so it seems to be a bug that was fixed in version 9. $\endgroup$ – Alexey Popkov Jan 4 '18 at 8:23
1
$\begingroup$

I reproduce the problem with version 8.0.4 on Windows 7 x64. The problem doesn't appear with versions 9.0.1, 10.0.1 and 11.2.0 on the same machine so it seems to be a bug that was fixed in version 9.

A workaround is to use CellPrint instead of Print for producing the InputField:

CellPrint[ExpressionCell[InputField[], "Print"]];
CellPrint[TextCell["my\"text", "Text", ShowStringCharacters -> True]];
$\endgroup$
0
$\begingroup$

(Posting the comment by Simon Woods as an answer.)

I can reproduce the problem with v8 on Windows 7. A workaround is to add a tiny pause between the two lines, e.g. I have posted this as an answer, Simon. It can be deleted if you would like to post your on answer.

Print[InputField[]];Pause[0.0001];CellPrint[blah...]
$\endgroup$
  • 1
    $\begingroup$ With this method I have to increase the pause to 0.1 in order to get it always working on my machine, the pause 0.0001 doen't work when the cell is evaluated for the first time. $\endgroup$ – Alexey Popkov Jan 4 '18 at 8:27

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.