Tapatalk

Incremental numbers at every found string

Incremental numbers at every found string

1
NewbieNewbie
1

PostSep 23, 2006#1

Hello,

Not a new UltraEdit user, but new to the forums . . .

I'm building source files and would like to find a quick, easy way to increment numbers, thusly . . .

I have [Source] (hundreds of them) and would like to make it

[source1]
...

[source2]
....

[source3]
...

and so on. Is there a way to do a search and replace, such as

Find [Source]
replace with [SourceN], [SourceN+1] ...

Or some other way to avoid manually typing more than 500 numbers in sequence?

Thanks in advance

Justin

6,825625
Grand MasterGrand Master
6,825625

PostSep 24, 2006#2

Once again a job for my universal macro CountUp. First you must create the macro CountUp posted at How to insert an incrementing number in a file using a counter in a macro?

It's important that you first create the submacro CountUp before creating the main macro with the PlayMacro command. This command will be automatically deleted without a warning from the main macro when closing the main macro editing if the CountUp macro is not already present in the macro file respectively loaded already into memory of UltraEdit.

The macro property Continue if a Find with Replace not found must be checked for the main macro. The main macro has following code for your usage:

Code: Select all

InsertMode
ColumnModeOff
HexOff
Top
"0"
Clipboard 9
StartSelect
Key LEFT ARROW
Cut
EndSelect
Loop
Find "[source]"
IfNotFound
ExitLoop
EndIf
EndSelect
Key LEFT ARROW
PlayMacro 1 "CountUp"
EndLoop
Top
ClearClipboard
Clipboard 0