在一行中将多个变量设置为相同的值

时间:2018-08-19 09:12:50

标签: applescript

嘿,我想知道是否有一种方法可以折叠这段代码,因此它不是12行设置变量。

当前代码:

coerce

我希望的是:

set isVideo to false
set isTV to false
set isMovie to false
set isRawVideo to false
set isDocumentary to false
set isAudio to false
set isSports to false
set isUnknown to false
set toPrompt to false
set BTNChoice to ""
set keyword to ""
set keywordHit to ""

或者:

set (isVideo, isTV, isMovie, isRawVideo, isDocumentary, isAudio, isSports, isUnknown, toPrompt) to false
set (BTNChoice, keyword, keywordHit) to ""

让我知道是否有一种方法可以减少这种情况,或者我是否每行都只能使用一个变量。

瑞安

1 个答案:

答案 0 :(得分:1)

唯一的一种方法是

set {isVideo, isTV, isMovie, isRawVideo, isDocumentary, isAudio, isSports, isUnknown, toPrompt} to {false, false, false, false, false, false, false, false, false}
set {BTNChoice, keyword, keywordHit} to {"", "", ""}

甚至是真实单线

set {isVideo, isTV, isMovie, isRawVideo, isDocumentary, isAudio, isSports, isUnknown, toPrompt, BTNChoice, keyword, keywordHit} to {false, false, false, false, false, false, false, false, false, "", "", ""}

右侧的项目数不得少于左侧的项目数。