On 24/02/2013 19:34, Oliver Taylor wrote:
On Feb 24, 2013, at 2:55 AM, ctfishman <[email protected]
<mailto:[email protected]>> wrote:
Is it possible to pass parameters to a script being run as a text filter?
No. You'd have to use an AppleScript to prompt for parameters and pass
those to your script (or something similar).
The parameters can be typed at the beginning of the document. For
example, you have a document with the text:
bag
lag
and you want to change all the a's to o.
Add lines to the beginning, so that you have:
a
o
bag
lag
When you run the filter below, the first two lines will supply your
parameters and be deleted. The remaining lines will be processed using
the arguments supplied, and you will end up with
bog
log
#!/usr/bin/perl
use strict;
my $i = 0;
my $param_1;
my $param_2;
while(<>){
$i++;
chomp ($param_1 = $_) and next if $i == 1;
chomp ($param_2 = $_) and next if $i == 2;
s~$param_1~$param_2~i;
print;
}
--
--
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 "[email protected]" 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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.