# Giving new input while program is running

This is a substantial edit of the initial question. Thanks to MikeLimaOscar I can narrow my problem to the use of Input. I want Mathematica to ask me for a value that I will give if I find a complex number. I keep getting Null when I use it. I give a basic example:

    Module[{n, , x, i},
Clear[n, x, i];
n = Sqrt[{4., -1., 9.}];
For[i = 1, i <= 3, i++,
If[Element[n[[i]], Reals] == True,
x[i] = n[[i]]*2,
x[i] = Input["Introduce a value"]
]
];
Table[x[i], {i, 1, 3}]]
{4., Null, 6.}


Why doesn't it take into consideration the number I give?

• Without even a hint of the structure of your code this is difficult to answer but using Input (and While) is certainly a possibility. For example, wrap your analysis function in something like: While[Im[Chop[result = yourAnalysis[a, t, initialGuess]]] != 0, If[(initialGuess = Input["Enter new initial guess"]) == \$Canceled, Abort[]]]. – MikeLimaOscar Nov 27 '17 at 17:40
• I'm unable to reproduce the issue. When I input 12.1, the output is {4., 12.1, 6.}. Perhaps try again with a fresh kernel? – jjc385 Nov 29 '17 at 6:35
• Are you using Mathematica online? If so this question is related. Otherwise, I think you may have set the dreaded option RequireReinstall to True! – MikeLimaOscar Nov 29 '17 at 17:46