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

时间:2021-06-03 17:07:34

标签: applescript

list view 作为参数传递给函数的正确方法是什么?如果我在函数内部设置 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

1 个答案:

答案 0 :(得分:1)

只有 Finder 知道什么是“列表视图”。

试试:

tell application "Finder" to 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
相关问题