如何将数组的长度声明为变量(··? 我需要先声明一个数组,然后输入以下代码中的选项,但输入数据的数量尚未确定。
tell application "Finder"
set TargetF to (path to desktop folder as text) & ""
set filePath to ""
set arrayfile to {"", "", "", "", "", ""}
select (every item where name extension is "mp4") of (TargetF as alias)
set sel to selection
if sel is not {} then
repeat with i from 1 to (count of sel)
set filePath to item i of sel as text
set item i of arrayfile to filePath
end repeat
end if
tell application "VLC" to open arrayfile
end tell
还有一个问题: AppleScript列错误 使用这些代码设置OS X窗口列的可见性失败
set width of column id name column of list view options of front window to 10
set visible of column id version column of list view options of front window to 1
答案 0 :(得分:0)
由于AppleScript中没有数组,因此您可以使用列表。这非常简单,您可以使用set beginning of L to yourvalue
或set end of L to yourvalue
并自动创建列表元素,因此列表的大小会动态增加(您需要先创建一个空列表,例如{ {1}}。在这里,您可以使用长度属性来读取列表的长度:set L to {}
,或者您可以对项目进行计数:set ll to length of L
。
如果您坚持使用静态数组,我会使用以下内容:
set ll to (count L)