Hi Chris,

Thank you for the answer.

I'm sorry for the late reply. I was not notified of your response. I will 
change the preferences for tracking responses in this group.

I will implement what you describe and come back here for feedback.

Le mercredi 21 septembre 2022 à 17:19:07 UTC+2, [email protected] a 
écrit :

> On Sep 20, 2022, at 10:46, Lionel <[email protected]> wrote:
>
>
> A call to the AppleScript library of BBEdit sometimes returns the number 
> of hits found, this is the case with replace.
>
> process lines containing text 1 of text document 1 matching string "^'" 
> output options {deleting matched lines:true} with matching with grep
>
> But with "process lines containing text" for example, this is not the case 
> and it is better to avoid testing the returned value. It must be somewhere 
> but not in the global property « result ». If someone has a solution, I'm 
> interested.
>
> ------------------------------
>
> Hey Lionel,
>
> BBEdit's *process lines containing* command does *not* return the number 
> of processed lines - period.
>
> You have to look at the actual output of the command.  When you do you 
> find it returns a record containing two items:
>
> modified text
> copied lines
>
> *Modified text* is what the text in your document is transformed into by 
> the command, and *copied lines* is the lines that are deleted.
>
> What's more – *copied lines* is always punctuated with a linefeed – even 
> when the last line deleted doesn't have one.
>
> So – you have to do something like this:
>
> --------------------------------------------------------
> # Auth: Christopher Stone
> # dCre: 2022/09/21 10:00
> # dMod: 2022/09/21 10:00 
> # Appl: BBEdit
> # Task: Return the Number of Processed Lines.
> # Libs: None
> # Osax: None
> # Tags: @Applescript, @Script, @BBEdit, @Processed, @Lines, 
> @Processed_Lines
> --------------------------------------------------------
>
> *tell* *application* "BBEdit"
> *tell* *front* *text window's* *text*
> *set* processLinesResultRecord *to* *process lines containing* matching 
> string "^[ts]" output options {deleting matched lines:*true*} *with* matching 
> with grep
> *end* *tell*
>
>
> *set* numberOfProcessedLines *to* copied lines *of* 
> processLinesResultRecord
>
>
> *if* numberOfProcessedLines ≠ "" *then*
> # Remove the extraneous linefeed at the end of 'copied lines'.
> *set* numberOfProcessedLines *to* *replace* "\\s\\z" using "" 
> searchingString numberOfProcessedLines options {search mode:*grep*}
> # Count the number of paragraphs to determine the number of processed 
> lines.
> *set* numberOfProcessedLines *to* length *of* (*get* *paragraphs* *of* 
> numberOfProcessedLines)
> *end* *if*
>
>
> *end* *tell*
>
> --------------------------------------------------------
>
> You could simply subtract 1 from the number of paragraphs instead of 
> munging the string as I have.
>
> I'm using BBEdit 14.1.2 on macOS 10.14.6 for this test.  I doubt the 
> newest version has changed much in this regard but can't be certain.
>
> --
> Best Regards,
> Chris
>
>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/4ef5a6e2-6636-488a-99ee-c92aad345134n%40googlegroups.com.

Reply via email to