繁体   English   中英

Applescript更改:复制结果列表不一样

[英]Applescript changes : copy the result as list isn't the same

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

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一样吗?

尝试:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM