试图学习如何使用AppleScript记录和列表到他们最高的潜力我一直在试图创建一个BBEdit项目的报告,但我发现非常有限的文档。我问了一个问题yesterday试图找出为什么我的查找模式不起作用,但发现问题来自我缺乏returning results:true
我能够获得结果记录,并且在读取Class并运行后验证它是记录:如何将一个AppleScript列表变成一个字符串
class of findFunction
因为它说,这是我回顾here跑length of findFunction
和count of findFunction
记录,他们都回来。我很好奇,想知道这两个项目都在记录,所以我用return findFunction
,被告知有:
found: true
found matches: list of X items
想知道在哪里和什么文件找到匹配在列表中,我做了一些更多的搜索和阅读Lists and records就跑:
set theMatches to get found matches of findFunction
它返回的列表项,并与get count of theMatches
检查新的变量我能获取记录内目标列表中的项目数量。当我回顾一下在列表中(学到:How to get a value from a list with a string in AppleScript?和Searching for items in list)我可以得出结论,在BBEdit中使用find
时,列表中的每个项目包含:
end_offset :
match_string :
message :
result_file :
result_kind :
result_line :
start_offset :
与我设置一个变量,一个项目做实验:
set itemOne to get item 1 of theMatches
,并查看其是否与工作:
display dialog (result_file of itemOne) as text
,并与完整的文件路径W的对话如显示。试图利用干我创建:
set filesResult to get (result_file of (get item 1 of theMatches)) as text
婉婷任何上述的东西,如添加到文件:
set filesResult to get (result_file of (get item 1 of theMatches)) as text
set theMessage to get (message of (get item 1 of theMatches)) as text
set combined to filesResult & ":" & theMessage
我记得能够使用剪贴板,发现Set clipboard to Applescript variable?所以我加:
set filesResult to the clipboard
make new text document
paste
,但我的问题我运行到是我怎么能抓住每一个项目在列表中found_matches
并将其添加到剪贴板中的项目在每一行?我想过使用一个repeat
,但我得到一个错误,当我尝试:
repeat with x from 1 to (length of matchesItems)
set filesResult to get (result_file of (get item x of theMatches)) as text
set theMessage to get (message of (get item x of theMatches)) as text
set combined to filesResult & ":" & theMessage
end repeat
随着消息:没有定义
变量matchesItems。
所以,我怎样才能从列表中的每一项与它自己的行每一个项目剪贴板上,这样我可以从剪贴板粘贴所有项目到一个新文件?