How to add an incremental sequence of numbers to a text file

General questions about using TextPad

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

Post Reply
Hjourzt
Posts: 2
Joined: Fri Dec 29, 2023 1:45 am

How to add an incremental sequence of numbers to a text file

Post by Hjourzt »

Greetings:

I have a text file that is a collection of numerical values that correspond to the pages and lines in a transcript. I use it as a script to create excerpts in an application called TrialDirector. I create the list manually, edit several times, but at the end I need to give each group of "designations" a unique three digit number, in sequence, starting from a given number, and put that number in two places in each set in the list.

What I start with is this:

Code: Select all

C(CLIP )
D(Smith Clip  )
26:11 - 18
26.22 - 27.13

C(CLIP )
D(Smith Clip  )
33:13 - 34:06 

C(CLIP )
D(Smith Clip  )
44:04 - 45.1
45.14 - 45:20  
What I want to end up with is this:

Code: Select all

C(CLIP 031)
D(Smith Clip 031)
26:11 - 18
26.22 - 27.13

C(CLIP 032)
D(Smith Clip 032)
33:13 - 34:06 

C(CLIP 033)
D(Smith Clip 033)
44:04 - 45.1
45.14 - 45:20  
Of course, these lists are anywhere from a dozen to hundreds long.

Can TextPad add a sequence of numbers (twice) to a thing like this? Your help is appreciated.
Last edited by AmigoJack on Sat Dec 30, 2023 11:11 am, edited 1 time in total.
Reason: formatting
Hjourzt
Posts: 2
Joined: Fri Dec 29, 2023 1:45 am

Re: How to add an incremental sequence of numbers to a text file

Post by Hjourzt »

Solved my own problem. I didn't think it could be done without coding a macro, but it turned out to be relatively simple. I found it by searching the help file for "Sequence".

Using the Replace function:

Code: Select all

     Find what:     C\(CLIP \)
     Replace with:  C\(CLIP \i{33,1,3,0}\)
That "i" means it will create an incremental number sequence. This put sequential numbers in the C pocket. Important: I have to use the "Replace All" button or it just started the sequence over from 033 every time I hit "Replace."

Then I did a similar thing for the D pocket:

Code: Select all

     Find what:     D\(Smith Clip  \)
     Replace with:  D\(Smith Clip \i{33,1,3,0}\)
As long as I started from the top and my lines were consistently written throughout, the same number appeared in the D pocket.

Saved a few hours with this.
Last edited by AmigoJack on Sat Dec 30, 2023 11:15 am, edited 1 time in total.
Reason: formatting; "Smith Clip" must search for 2 spaces (not 1) and replace with "D" (not "C")
User avatar
AmigoJack
Posts: 482
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Re: How to add an incremental sequence of numbers to a text file

Post by AmigoJack »

Follow-up: if one also needs to use \\ in front of the \i replacement parentheses are needed.
Post Reply