Re: Scripts

2021-06-28 Thread Christopher Stone
On 06/28/2021, at 04:35, Paul G mailto:p...@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

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/5966CF7B-80BF-4D13-871F-96981C854A9D%40gmail.com.


Re: Scripts

2021-06-28 Thread Patrick Woolsey

On 6/28/21 at 5:35 AM, p...@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. 

--
This is the BBEdit Talk public discussion group. If you have a feature request or need 
technical support, please email "supp...@barebones.com" rather than posting here. 
Follow @bbedit on Twitter: 
--- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/r480Ps-10146i-FE8FCFEC6D0C4D8495B79927B3ED2B4D%40Cylinder.local.


Re: Scripts

2021-06-28 Thread MediaMouth


> On Jun 28, 2021, at 05:48, Paul G  wrote:
> 
> 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
> -- 
> This is the BBEdit Talk public discussion group. If you have a feature 
> request or need technical support, please email "supp...@barebones.com" 
> rather than posting here. Follow @bbedit on Twitter: 
> 
> --- 
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/bbedit/0f2a4a5b-c781-47ca-8a9c-b118733ec61en%40googlegroups.com.

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/6F2DDDBB-450B-450D-8D3C-0C90FC22EC23%40gmail.com.


Re: Scripts to send command files to Stata/R selected text to Stata

2013-07-01 Thread Steve Samuels



  There are other scripts around.  For R, see: 
https://files.nyu.edu/jmb736/public/projects/R.html

On Friday, June 28, 2013 5:40:28 PM UTC-4, Steve Samuels wrote:

 Stata 13 changed its scripting behavior and broke the previous scripts. 
 I've revised them to work with any Stata version.
 The scripts are written for StataMP; if you use a different flavor, 
 substitute its name.  The Send_to_Stata_or_R script
 checks the file extension (do for Stata, R or r for R)  to know 
 which app is the target.






-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.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+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.




Re: Scripts to send command files to Stata/R selected text to Stata

2013-06-29 Thread Neil Tiffin
Excellent, I did not know these existed and they will make my R work much 
easier.

Neil

On Jun 28, 2013, at 7:35 PM, Steve Samuels sjsamu...@gmail.com wrote:

 
 I should have added that Ben Hulley was the author of the originals of these 
 scripts. See the header material of the Send_to_Stata_or_R  for some other 
 sources of that script. I  modified or added only about six of 58 lines in  
 Ben's original Send_Selection_To_Stata .
 

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.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+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.




Re: Scripts to send command files to Stata/R selected text to Stata

2013-06-28 Thread Steve Samuels

I should have added that Ben Hulley was the author of the originals of 
these scripts. See the header material of the Send_to_Stata_or_R  for 
some other sources of that script. I  modified or added only about six of 
58 lines in  Ben's original Send_Selection_To_Stata .






-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.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+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.




Re: Scripts that report information about selected text?

2011-08-10 Thread Bruce Van Allen

On 2011-08-10, rowen wrote:


I'd want to write a script that reports the sum and mean of a column
of numbers that are selected using column selection.

I have a Python text filter that does this now with normally selected
text (working on the first number found on each line), but it writes
the information after the selected text (by echoing the input and then
writing the new info). That technique won't work with a column
selection; there's no obvious place to safely write the results.

I would prefer to open a new window and write the results there. Is
there some easy way to do this? From a Python script?


My Python is minimal, but this would be trivial with regular 
expressions in Perl, without even selecting the column beforehand.


But you might be able to do without going outside of BBEdit -- 
are you familiar with Text - Process Lines Containing...  ?




   - Bruce

_bruce__van_allen__santa_cruz_ca_

--
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.

To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email supp...@barebones.com rather than posting to the group.

Follow @bbedit on Twitter: http://www.twitter.com/bbedit


Re: Scripts that report information about selected text?

2011-08-10 Thread John Delacour

At 11:00 -0700 10/08/2011, rowen wrote:



I'd want to write a script that reports the sum and mean of a column
of numbers that are selected using column selection.

I have a Python text filter that does this now with normally selected
text (working on the first number found on each line), but it writes
the information after the selected text (by echoing the input and then
writing the new info). That technique won't work with a column
selection; there's no obvious place to safely write the results.

I would prefer to open a new window and write the results there. Is
there some easy way to do this? From a Python script?



I don't know Python but here's how you could do it in Perl

You have to copy your selection onto the clipboard because the text 
filters read whole lines.  Overwrite the selection, then create a 
file for your results.  Perform your calculations on $clipboard, 
write the results to the new file and open this in BBEdit.


This script multiplies every number in your selected column by 2 and 
displays the results in the doc $tempfile:



#! /usr/bin/perl
use strict;
my $clipboard = `pbpaste`;
my $tempfile = /tmp/temp.txt;
while () {print}
open FH, , $tempfile or die $!;
for (split /[\n\r]/, $clipboard){
  $_ *= 2;
  print FH $_\n;
}
`open -a bbedit $tempfile`;

JD


--
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.

To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email supp...@barebones.com rather than posting to the group.

Follow @bbedit on Twitter: http://www.twitter.com/bbedit