Wolfram mathematica 在弹出框中不计算输入?

Wolfram mathematica 在弹出框中不计算输入?,wolfram-mathematica,Wolfram Mathematica,我有以下mma代码: $ButtonOptions = {Method -> "Queued"}; Button["Get List of IDs", ai = ToString@Input["Please Enter ID#s", {}]; ai = StringReplace["ai", "\[Times]" -> ","]; Print@ai, Background -> Yellow, Sequence @@ $ButtonOptions ] 当输

我有以下mma代码:

$ButtonOptions = {Method -> "Queued"};
Button["Get List of IDs",
  ai = ToString@Input["Please Enter ID#s", {}];
  ai = StringReplace["ai", "\[Times]" -> ","];
  Print@ai,
  Background -> Yellow, Sequence @@ $ButtonOptions
  ]

当输入窗口弹出时,我需要用户在这些括号中输入多个ID号。他们喜欢使用Excel并在列中粘贴,但这会为每个ID号生成一个新的段落(Mathematica将其转换为一个空格,然后转换为乘法,然后将所有ID相乘)。我需要一些方法来防止输入在输入时计算,而不让
Hold
实际显示在输入框中,这样
StringReplace
操作将起作用,并在Mathematica将ID相乘之前消除所有换行符。

使用
InputString
怎么样

Button["Get List of IDs",
 ai = InputString["Please Enter ID#s", {}];
 ai = DeleteCases[StringSplit[ai, WhitespaceCharacter | ","], ""];
 Print[ai],
 Method -> "Queued"]

当然,您可能希望对ID的类型进行更多检查。在上面的代码中,我使用了
StringSplit
来分隔空格、制表符、换行符和逗号处的字符串,但这可能有点过于简单,对于实际使用来说不够健壮。

我添加了
$ButtonOptions={Method->“Queued”}
Print
之前的分号,以便代码可以按原样运行(但仍然不能做你想做的事)。