AppleScript 如何找到模式并将其设置为记录或列表?
AppleScript how to find pattern and set it to a record or list?
在 AppleScript 中,我知道如何使用类似的东西进行典型的查找:
tell application "BBEdit"
activate
open find window
find "memberFunction\(\)" searching in text 1 of text document "theFile" options {search mode:grep, wrap around:true} with selecting match
end tell
我可以进行多文件搜索找到:
tell application "BBEdit"
activate
find "memberFunction\(\)" searching in {file "path:to:project.bbprojectd:"} options {search mode:grep, showing results:true}
end tell
但我想 return 查找多个结果并将其保存到文件中,所以我认为我需要将其保存到记录或列表中然后重复输入,但是当我尝试:
tell application "BBEdit"
activate
set findFunction to {}
set findFunction to {find "memberFunction\(\)" searching in {file "path:to:project.bbprojectd:"} options {search mode:grep, showing results:true}} as list
end tell
或:
set findFunction to {find "memberFunction\(\)" searching in {file "path:to:project.bbprojectd:"} options {search mode:grep, showing results:true}} as record
我得到一个错误:
No result was returned from some part of this expression.
为什么没有将查找设置到记录或列表?有什么方法可以设置多文件搜索的功能吗?
错误是您将 find
命令放在列表中。
To get a record from the find command:
The showing results
property must be false and the returning
results
property must be true, otherwise the findFunction
variable will be undefined
这是脚本:
tell application "BBEdit"
set findFunction to find "memberFunction\(\)" searching in file "path:to:project.bbprojectd:" options {search mode:grep, showing results:false, returning results:true}
end tell
在 AppleScript 中,我知道如何使用类似的东西进行典型的查找:
tell application "BBEdit"
activate
open find window
find "memberFunction\(\)" searching in text 1 of text document "theFile" options {search mode:grep, wrap around:true} with selecting match
end tell
我可以进行多文件搜索找到:
tell application "BBEdit"
activate
find "memberFunction\(\)" searching in {file "path:to:project.bbprojectd:"} options {search mode:grep, showing results:true}
end tell
但我想 return 查找多个结果并将其保存到文件中,所以我认为我需要将其保存到记录或列表中然后重复输入,但是当我尝试:
tell application "BBEdit"
activate
set findFunction to {}
set findFunction to {find "memberFunction\(\)" searching in {file "path:to:project.bbprojectd:"} options {search mode:grep, showing results:true}} as list
end tell
或:
set findFunction to {find "memberFunction\(\)" searching in {file "path:to:project.bbprojectd:"} options {search mode:grep, showing results:true}} as record
我得到一个错误:
No result was returned from some part of this expression.
为什么没有将查找设置到记录或列表?有什么方法可以设置多文件搜索的功能吗?
错误是您将 find
命令放在列表中。
To get a record from the find command:
The
showing results
property must be false and thereturning results
property must be true, otherwise the findFunction variable will be undefined
这是脚本:
tell application "BBEdit"
set findFunction to find "memberFunction\(\)" searching in file "path:to:project.bbprojectd:" options {search mode:grep, showing results:false, returning results:true}
end tell