How do you input a list of numbers via InputField
and immediately generate their sum (or whatever other operation involving a list of numbers) underneath.
I've tried with ImportString
:
DynamicModule[{x}, Column[{InputField[Dynamic[x], String, ContinuousAction -> True], Dynamic[Activate@Plus[Delete[#, 0] &@ImportString[x, "List"]]]}]]
Also with ToExpression
:
Column[{InputField[Dynamic[x], String, ContinuousAction -> True], Dynamic[xNum = ImportString[x, "List"]], Dynamic[Activate@Plus@Delete[xNum, 0]]}]
Neither one works...
DynamicModule[{x = "", xc = {}}, Column[{InputField[Dynamic[x], String, ContinuousAction -> True], Dynamic[xc = ImportString[x, "List", "LineSeparators" -> ","]], Dynamic[Total[xc]]}]]
. $\endgroup$