AppleScript如何查找模式并将其设置为记录或列表? [英] AppleScript how to find pattern and set it to a record or list?

查看:344
本文介绍了AppleScript如何查找模式并将其设置为记录或列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在AppleScript中,我知道如何做一个典型的查找:

 告诉应用程序BBEdit
激活
打开查找窗口
找到memberFunction \\(\\)在文本文档1中搜索theFile选项{search mode:grep,wrap around:true}匹配
结束告诉

我可以做一个多文件搜索find:

  tell applicationBBEdit
activate
findmemberFunction\\(\\)searching in {filepath:to:project.bbprojectd:} options {search mode:grep,showing results:true}
end tell

但我想返回查找多个结果并将其保存到一个文件,所以我想我需要将它保存到一个记录或列表,然后重复通过输入,但是当我告诉应用程序BBEdit
激活
设置findFunction为{}
设置

  findFunction t o {find \\ memberFunction \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' end tell 

或者:

 {code>将findFunction设置为{findmemberFunction \\(\\)在{file路径中搜索到:project.bbprojectd:} options {search mode:grep,显示结果: }}作为记录

我得到一个错误:


这个表达式的一部分没有返回结果。

为什么找到没有被设置为记录或列表?有没有一种方法可以设置多文件搜索的功能?

解决方案

错误是你把<$ c


$ b


到$ c $>在列表中找到命令。从find命令获得一条记录:
$ b $ 显示结果属性必须为 false 并且返回
结果
属性必须为 true ,否则 findFunction
变量将为undefined


以下是脚本:

 告诉应用程序BBEdit
设置findFunction找到memberFunction \\(\\)在文件路径搜索:project.bbprojectd:options {search mode:grep,显示结果:false,返回结果:true}
end tell


In AppleScript I know how to do a typical find with something like:

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

and I can do a multi file search find:

tell application "BBEdit"
    activate
    find "memberFunction\\(\\)" searching in {file "path:to:project.bbprojectd:"} options {search mode:grep, showing results:true}
end tell

but I'd like to return the find multi result and save it to a file so I thought I'd need to save it to a record or list then repeat through the input but when I try:

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

or:

set findFunction to {find "memberFunction\\(\\)" searching in {file "path:to:project.bbprojectd:"} options {search mode:grep, showing results:true}} as record

I get an error of:

No result was returned from some part of this expression.

Why is the find not being set to the record or list? Is there a way I can set what the multi-file search does?

解决方案

The error is that you put the find command in a list.


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

Here's the script:

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如何查找模式并将其设置为记录或列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆