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

Recursion AppleScript:如何将子例程参数传递给另一个子例程,recursion,applescript,Recursion,Applescript,我有一个AppleScript,我正试图将其模块化以供将来使用。工作正常:一个脚本,递归地遍历嵌套的查找器文件夹。我想要的是:该脚本使用自己的参数调用另一个子例程 示例代码(带有一个可工作的递归函数),其中我对需要帮助的部分使用带注释的伪代码: on recurseFolders_runSubroutine(thisItem, subName, subParameters, notify) global itemcount try set itemcount to

我有一个AppleScript,我正试图将其模块化以供将来使用。工作正常:一个脚本,递归地遍历嵌套的查找器文件夹。我想要的是:该脚本使用自己的参数调用另一个子例程

示例代码(带有一个可工作的递归函数),其中我对需要帮助的部分使用带注释的伪代码:

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

我在运行脚本上尝试了一些变体,并使用文本字符串调用函数,但是我无法将子参数列表作为列表传递。我遗漏了什么吗?

调用脚本的
子名称处理程序的语法是,例如
告诉myScript子名称(“howdy”)
。AppleScript中没有
eval
;您不能将任意字符串转换为该调用。您可以将脚本构造为字符串,并告诉
osascript
通过
do shell script
命令编译并运行它,这将需要将大量内容强制转换为字符串,但是的,我认为这是一种可能的解决方法。