Scripts

31 просмотр
Перейти к первому непрочитанному сообщению

Paul G

не прочитано,
28 июн. 2021 г., 08:48:0828.06.2021
– BBEdit Talk
Hey All.

Would anyone be up to writing a couple of basic scripts for me to use in BBEdit?
If so let me know price.

I just need a script to alphabetically sort lines within certain parameters inside a text doc and another to replace certain text within a text doc.

I know this may be simple but do not have knowledge or time to do this myself.

Any help much appreciated.

Cheers,

Paul

MediaMouth

не прочитано,
28 июн. 2021 г., 09:13:2428.06.2021
– bbe...@googlegroups.com


On Jun 28, 2021, at 05:48, Paul G <pa...@profile-music.com> wrote:

Hey All.
--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" 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 bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/0f2a4a5b-c781-47ca-8a9c-b118733ec61en%40googlegroups.com.

Patrick Woolsey

не прочитано,
28 июн. 2021 г., 14:08:3328.06.2021
– bbe...@googlegroups.com
On 6/28/21 at 5:35 AM, pa...@profile-music.com (Paul G) wrote:

[...]
>I just need a script to alphabetically sort lines within
>certain parameters inside a text doc and another to replace
>certain text within a text doc.
>
>I know this may be simple but do not have knowledge or time to
>do this myself.


Since it may be that you don't even need script(s) but could
instead just create (one or a pair of) text factories, may I
suggest you provide an example of each task, along with a bit of
actual data?


Regards

Patrick Woolsey
==
Bare Bones Software, Inc. <https://www.barebones.com/>

Christopher Stone

не прочитано,
28 июн. 2021 г., 22:43:5028.06.2021
– BBEdit-Talk
On 06/28/2021, at 04:35, Paul G <pa...@profile-music.com> wrote:
Would anyone be up to writing a couple of basic scripts for me to use in BBEdit?
If so let me know price.

I just need a script to alphabetically sort lines within certain parameters inside a text doc and another to replace certain text within a text doc.


Hey Paul,

Replacing text with AppleScript is easy enough once you know how:

-------------------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2021/06/28 21:28
# dMod: 2021/06/28 21:37
# Appl: BBEdit
# Task: Replace Either RegEx or Literal Text in the Designated BBEdit Window.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Replace, @RegEx, @Literal
-------------------------------------------------------------------------------------------

# Use "Front_Text_Window" to Target the Front Window.
# Otherwise use the Window Name as the targetWindow.

# REMEMBER - The backslash for RegEx metacharacters "\" must be escaped in AppleScript "\\".

# Verbose:
set matchStr to "Nyet\\s"
set replaceStr to "Da"
set targetWindow to "Front_Text_Window"
set grepFlag to {|regEx|:true}
bbeditReplaceMatchInTargetWindow(matchStr, replaceStr, targetWindow, grepFlag)

# Less Verbose:
# bbeditReplaceMatchInTargetWindow("Nyet\\s", "Da", "Front_Text_Window", {|regEx|:true})

-------------------------------------------------------------------------------------------
--» HANDLERS
-------------------------------------------------------------------------------------------
on bbeditReplaceMatchInTargetWindow(matchStr, replaceStr, targetWindow, grepFlag)

    

    tell application "BBEdit"
        if targetWindow = "Front_Text_Window" then
            set targetWindowRef to a reference to the front text window
        else
            set targetWindowRef to a reference to text window targetWindow
        end if

        

        if grepFlag's |regEx| = true then
            set searchModeType to grep
        else
            set searchModeType to literal
        end if

        

        # Case-Sensitive is OFF by Default – Switch on using (?-i)
        tell targetWindowRef's text
            replace matchStr using replaceStr options {search mode:searchModeType, starting at top:true}
        end tell

        

    end tell

    

end bbeditReplaceMatchInTargetWindow
-------------------------------------------------------------------------------------------

Sorting lines “within certain parameters” requires more explanation.  Please provide real world examples.

--
Best Regards,
Chris

Ответить всем
Отправить сообщение автору
Переслать
0 новых сообщений