苹果脚本更改:将结果复制为列表不一样



我最近在我的一些应用程序中发现了一个错误,这些应用程序在最近的计算机上运行。这个错误来自appscriptive提出的问题,并试图得到两个答案:文本答案和返回的按钮。基本上,这是一种脚本:

display dialog "This is a question" default answer "the text answer" buttons {"button 1", "button2", "button 3"}
copy the result as list to {"the_text", "the_button"}

"将结果复制为列表"是我找到的保存两个答案的唯一方法,但问题是:在10.7中,appdescription按以下顺序返回结果:文本返回,按钮返回。在10.9中,appescription以相反的顺序返回结果,先是按钮,然后是文本。那么使用答案是不可能的。你知道我可以把这两个答案都保存下来,让它在10.7和10.9上一样有效吗?

尝试:

set {text returned:the_text, button returned:the_button} to display dialog "This is a question" default answer "the text answer" buttons {"button 1", "button2", "button 3"}

编辑

通过将结果强制到列表中,您将无法再识别返回的按钮和返回的文本属性。

比较一下:

display dialog "This is a question" default answer "the text answer" buttons {"button 1", "button2", "button 3"}

这个:

display dialog "This is a question" default answer "the text answer" buttons {"button 1", "button2", "button 3"}
return the result as list

这是adayzone答案的一个略有不同的版本。它读起来更像Python的元组解包。

一个衬垫:

set {the_text, the_button} to {text returned, button returned} of (display dialog "This is a question" default answer "the text answer" buttons {"button 1", "button2", "button 3"})

使用result中间变量:

display dialog "This is a question" default answer "the text answer" buttons {"button 1", "button2", "button 3"}
set {the_text, the_button} to {text returned, button returned} of the result

最新更新