Applescript 将值作为参数传递给处理程序

Applescript 将值作为参数传递给处理程序,applescript,Applescript,将列表视图作为参数传递到函数中的正确方法是什么?如果我在函数内部设置view_type,它会工作,但如果我在函数外部设置view_type,它不会工作 #works the_function() on the_function() tell application "finder" set view_type to list view set current view of window 1 to view_type end t

列表视图
作为参数传递到函数中的正确方法是什么?如果我在函数内部设置view_type,它会工作,但如果我在函数外部设置view_type,它不会工作

#works
the_function()
on the_function()
    tell application "finder"
        set view_type to list view
        set current view of window 1 to view_type
    end tell
end the_function

#fails
set view_type to list view
the_function(view_type)
on the_function(view_type)
    tell application "finder"
        set current view of window 1 to view_type
    end tell
end the_function

只有查找者知道什么是“列表视图”

尝试:

你也可能会变得棘手,比如:

the_function("lsvw" as constant) # lsvw, clvw, flvw, or icnv .

on the_function(view_type)
    tell application "Finder"
        set current view of window 1 to view_type
    end tell
end the_function

太好了,谢谢。第二条路是我需要的。后续问题:您将
列表视图
更改为
lsvw
。你怎么知道要这么做?是否有一个参考可以让我参考,它给出了等价的applescript表示:列表视图=lsvw,列视图=clvw,等等?我认为这是applescript内部的,可能没有很好的文档记录,或者可能会发生更改。我通过以下方式获得属性值(抱歉格式不好):
tell application“Finder”日志列表视图为«class utf8»日志列视图为«class utf8»日志图标视图为«class utf8»日志流视图为«class utf8»end tell
您也可以使用,这将允许您查看原始源。
the_function("lsvw" as constant) # lsvw, clvw, flvw, or icnv .

on the_function(view_type)
    tell application "Finder"
        set current view of window 1 to view_type
    end tell
end the_function