Incremental numbers at every found string

Help with writing and playing macros

Incremental numbers at every found string

Postby fsgenesis » Sat Sep 23, 2006 3:21 pm

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
User avatar
fsgenesis
Newbie
 
Posts: 1
Joined: Fri Sep 22, 2006 11:00 pm

Re: Incremental numbers at every found string

Postby Mofi » Sun Sep 24, 2006 10:09 am

Once again a job for my universal macro CountUp. First you must create the macro CountUp posted at counter ?

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.

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:

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
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4055
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Macros