Block Numbers Resequence

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Danny

Block Numbers Resequence

Post by Danny »

I have block numbers that looks like this

N0010 R470=1 L870
N0020 (G54)R50=0R51=163.R52=0R53=1L798
N0030 G00 G40 G54 G80 G90
N0040 L861
N0050 M01

I use the find and replace functions to resequence the block number

Find : \N[0-9][0-9][0-9][0-9]
Replace : \N\i(5,5)

N5 R470=1 L870
N10 (G54)R50=0R51=163.R52=0R53=1L798
N15 G00 G40 G54 G80 G90
N20 L861
N25 M01

The problem I'm having is keeping the leading zeros.
(ie. N0005 and not N5)

I've tried \N\i(0005,0005), same result

Any Ideas !!!

Thanks
Pete Cahill

Re: Block Numbers Resequence

Post by Pete Cahill »

Can't think of a way of doing it in a single pass but you can effectively do it in two passes from the point you've already got to:

You have

N5
N10
N255
etc

Replace ^N with N000 to get

N0005
N00010
N000255
etc

Now replace \N0\([0-9][0-9][0-9][0-9]\) with N\1 and repeat until you get no more substitutions. See Tagged Expressions in the help file
Roy Beatty

Re: Block Numbers Resequence

Post by Roy Beatty »

All,

I just figured out how to create a column of padded values from \i -- only 2 passes:

In the Replace expression use \i(n,5) where n is a sufficiently large value to create the padded of zeroes that you need. Then Find and Replace again to eliminate the leading numeric character(s):

Find:::: ^
Replace: N\i(70005,5)

Find:::: ^N7
Replace: N

Hope someone is still reading this thread,

Roy
Post Reply