2014-10-17 81 views
3

我最近发现我的一些苹果脚本在最近的计算机上运行它们的错误。问题来自苹果电脑提出的问题,并试图得到两个答案:文本答案和返回的按钮。基本上,这是一种脚本:苹果脚本更改:复制结果列表是不一样

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,AppleScript的返回结果这命令:返回文本,返回按钮,并且在10.9中,applescript按照相反的顺序返回结果,首先是按钮,然后是文本 然后使用答案是不可能的你知道一种方法可以保存答案和让它在10.7上10.9工作

回答

2

尝试:?

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 
+0

它接缝做工精细,但它并没有听起来自然写信给我:) – 2014-10-17 16:06:45

0

这里有一个稍微不同的版本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