AppleScript:如何将子例程参数传递给另一个子例程

时间:2018-04-14 21:20:29

标签: recursion applescript

我有一个AppleScript,我正在尝试模块化以备将来使用。工作正常:递归遍历嵌套Finder文件夹的脚本。我想要的:该脚本使用自己的参数调用另一个子例程。

示例代码(带有工作递归功能),我正在使用注释伪代码来处理我需要帮助的部分:

on recurseFolders_runSubroutine(thisItem, subName, subParameters, notify)
    global itemcount
    try
        set itemcount to itemcount + 1
    on error
        set itemcount to 1
    end try

    tell application "Finder"
        if notify then display notification ("Recursing into folder ") & name of thisItem with title "Entering Folder"
        if kind of thisItem is "Folder" then
            set subItems to every item in thisItem
            set countItems to count subItems
            repeat with i from 1 to countItems
                set subItem to item i of subItems
                my recurseFolders_runSubroutine(subItem, subName, subParameters, notify, itemcount)
            end repeat
        else
            -- tell script ("subName" & .scpt) to [call subroutine named subName with the parameters, presumably passed in a list]
        end if
    end tell
end recurseFolders_runSubroutine

我尝试使用运行脚本的一些变体,使用文本字符串来调用函数,但是我不能将子参数列表作为列表传递。我错过了什么吗?

0 个答案:

没有答案