At 08:10 -0700 21/06/2011, Warren Michelsen wrote:

What I'd prefer, of course, is a more generalized solution that can handle any number of columns and delete any column designated. So I'm wondering if maybe a shell script is the solution. I often employ Perl scripts saved within the script application bundle. AS does some prep and then the Perl script is called to do the heavy lifting.

Since I don't think it's possible to pass arguments to a BBEdit Unix Filter, you can create the filter using Applescript.

This simple example asks which number you want to replace in the front window, and then writes the Unix Filter with this added as a variable. If you type 2 in the dialog, all the 2s will be changed to "<2>".

tell application "BBEdit"
  activate
  set _dd to display dialog "Type a digit?" default answer ""
  set _number to text returned of _dd
  set _appsup to "" & (path to application support from user domain)
  set _unixfilters to _appsup & "BBEdit:Unix Support:Unix Filters:"
  set _perlscript to _unixfilters & "temp.pl"
  try
    close access file _perlscript
  end try
  set _fh to open for access file _perlscript with write permission
  set eof _fh to 0
  write my SCRIPT_TEXT(_number) to _fh
  close access _fh
  run unix filter alias _perlscript
end tell
on SCRIPT_TEXT(_n)
  return "#!/usr/bin/perl
my $n = qq~" & _n & "~;" & "
while (<>){
  s/$n/<$n>/g;
  print;
}"
end SCRIPT_TEXT

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>

Reply via email to