Chris S, I tried your script, but nothing appears to happen. No changes.
I made mods to your code. I was not as clear as I should have been on
explanation desired results.
What I am working on is 50 chapters which are of the format:
#start#
1 xxxxxx
2 xxxxxxx
….
n xxxxxxx
#endofGen#
What I am trying to do is after I find a start, then the next line should be a
1 and text. I want to change that 1 to whatever the current chapter number it
should be. All the chapters ar in order. Example for 20 chapter, the output
would look like:
#start#
20 xxxxxx
2 xxxxxxx
….
n xxxxxxx
#endofGen#
That line starting with a 1 and following a start is the only change desired.
I am on MacOS 10.15.7 and the very latest BBEdit 14.0.5. The Perl I am
executing is 5.28.2.
I get no errors when I run the the filter.
Here is what I have as a script after my minor changes:
my $cntr = 0;
my $ChgSw = 0;
while (<>) {
if ( /^#Start#/i ) {
$cntr++;
$ChgSw = 1;
}
if ( $ChgSw ) {
if ( /^1\h/ ) {
s!^1!$cntr!;
}
$ChgSw = 0;
}
print;
}
Sorry for delay in getting back to you. I truly appreciate the insight from
what I see in the scripts and the way they work with BBEdit.
Wags ;)
WagsWorld
Hebrews 4:15
Ph(primary) : 408-914-1341
Ph(secondary): 408-761-7391
On Jan 6, 2022, 04:56 -0800, Christopher Stone <[email protected]>,
wrote:
> Hey Chris,
>
> This fails on my Mojave system with the stock `awk`.
>
>
> #Start#Start#Start#
> 2 In the beginning, God created the heavens and
> Xxxxxxccx
> #Start#EndOfGen#Start#
> #Start#Start#Start#
> 6 Thus the heavens and the earth were finished,
> Xxxxxxxx
> #Start#EndOfGen#Start#
> #Start#Start#Start#
> 10 Now the serpent was more crafty than any other beast of the field that the
> LORD God had made.
> Xxxxxxx
> #Start#EndOfGen#Start#
>
>
> It works if I use the current version of `gawk`.
>
> It looks like David has an older version of macOS as well.
>
> --
> Take Care,
> Chris
>
>
> > On Jan 05, 2022, at 21:52, Christopher Waterman <[email protected]>
> > wrote:
> >
> > Sorry David,
> >
> > I did make a mistake but the output you're getting still confuses me.
> > All my chapter numbers were off by one, but that was it.
> >
> > Anyway here is the fixed script. ( I think 🤞)
> >
> > I provided an example of my input and output, also a screenshot.
> > Be sure to copy the script exactly.
> >
> > #!/usr/bin/env awk -f
> >
> > BEGIN {
> > RS = "#Start#"
> > ORS = ""
> > FS = "\n"
> > OFS = "\n"
> > }
> >
> > {
> > sub( /[0-9]+/, NR-1 , $2 )
> > }
> >
> > NR != 1 {
> > print "#Start#" $0
> > }
> >
> > Input:
> > #Start#
> > 1 In the beginning, God created the heavens and
> > Xxxxxxccx
> > #EndOfGen#
> > #Start#
> > 1 Thus the heavens and the earth were finished,
> > Xxxxxxxx
> > #EndOfGen#
> > #Start#
> > 1 Now the serpent was more crafty than any other beast of the field that
> > the LORD God had made.
> > Xxxxxxx
> > #EndOfGen#
>
> --
> 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/18DA528B-9E6C-4B84-BAD4-1462489AB0ED%40gmail.com.
--
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/f7c8ebd0-5f52-490b-95df-7500b9b6f958%40Spark.