逻辑不使用Applescript中的List项目

时间:2016-09-28 19:20:22

标签: applescript

这是一个非常奇怪的问题,我无法理解,代码很清楚,你可以看到,我不知道我是否累了或看不到的东西......请告诉我为什么我会得到假因此,虽然它应该是True,但我有一个包含一个项目的列表,它是变量中的确切列表 谢谢

property forbidenFolders : {"/Volumes/USERS/"}
set ff to "/Volumes/USERS/" as text
my isForbidenFolder(ff)
on isForbidenFolder(SelectedFolder)
    repeat with i in forbidenFolders
        log "forbiden folders: " & i
        log "actual folder   : " & SelectedFolder
        if i = SelectedFolder then
            log "this folder is forbiden"
            return true
        end if
    end repeat
    log "NOT forbiden"
    return false
end isForbidenFolder

结果在这里

enter image description here

2 个答案:

答案 0 :(得分:0)

当我在重复循环中设置为列表项时,您将获得对该项的引用。您需要将其强制转换为字符串以供比较。

if (i as string) = SelectedFolder

答案 1 :(得分:0)

这是参考陷阱。

语法repeat with item in list通过引用遍历列表,例如a reference to item 1 of lista reference to item 2 of list等,而非项目本身。

为了能够检查是否相同,您必须使用contents of

取消引用该项目
if contents of i = SelectedFolder then
相关问题