If statement AppleScript列表/包含

If statement AppleScript列表/包含,if-statement,applescript,contain,If Statement,Applescript,Contain,我不明白这为什么不起作用。 变量是iphone6plus银色128GB-AUS,因此实际上包含列表中的iphone6plus 如果我在列表中使用if,它可以正常工作,但是我必须将所有不同的模型设置为一个变量 如何进行部分匹配?可以检查字符串是否在列表中,但不能检查任意列表项是否在字符串中。你必须一个接一个地重复所有的项目 set r to "" set device to "IPHONE 6 PLUS SILVER 128GB-AUS" set HighValueDevicesPass to {

我不明白这为什么不起作用。 变量是iphone6plus银色128GB-AUS,因此实际上包含列表中的iphone6plus

如果我在列表中使用if,它可以正常工作,但是我必须将所有不同的模型设置为一个变量


如何进行部分匹配?

可以检查字符串是否在列表中,但不能检查任意列表项是否在字符串中。你必须一个接一个地重复所有的项目

set r to ""
set device to "IPHONE 6 PLUS SILVER 128GB-AUS"
set HighValueDevicesPass to {"IPHONE 7", "IPHONE 6", "IPAD PRO", "IPHONE 6S", "IPHONE 6 PLUS"}

if devices contains HighValueDevicesPass then
    set r to "Pass"
end if
return r
我还删除了iphone6s和iphone6plus的值,因为它们已经由iphone6字符串匹配

set r to ""
set device to "IPHONE 6 PLUS SILVER 128GB-AUS"
set HighValueDevicesPass to {"IPHONE 7", "IPHONE 6", "IPAD PRO"}

repeat with i from 1 to count HighValueDevicesPass
    if device contains item i of HighValueDevicesPass then
        set r to "pass"
        exit repeat
    end if
end repeat

return r