Find/Replace with counting function question...

Help with writing and playing macros

Find/Replace with counting function question...

Postby officerspock » Tue Jul 10, 2007 6:47 pm

Hello!

I have a file where I will be doing a find/replace, but I want to replace with values that increment. Is this possible to do so in a UE Macro?

Scenario is as follows...

Searching for \0\ and starting with 0, replacing with \X\. After 100 replaces, change X to 1. After another 100, change X to 2 and so on until the end of the file is reached.

I've combed through these forums, but haven't found much. Any ideas?

:idea:
User avatar
officerspock
Newbie
 
Posts: 2
Joined: Mon Jul 09, 2007 11:00 pm

Re: Find/Replace with counting fucntion question...

Postby Mofi » Wed Jul 11, 2007 6:38 am

Sure, this is possible. First you have to create my universal CountUp macro posted at counter ? and also packed into the zip-archive ready for usage at Macro examples and reference for beginners and experts.

Then you have to create an additional macro which does the 100 replaces in a loop and has following content:

Loop 100
Find "\0\"
Replace "\^c\"
IfNotFound
ExitLoop
EndIf
EndLoop

Name this macro for example Replace100.

And last you have to create the main macro which calls this 2 submacros.

The macro property Continue if a Find with Replace not found must be checked for all these macros.

InsertMode
ColumnModeOff
HexOff
Top
"0"
Clipboard 9
StartSelect
Key LEFT ARROW
Cut
EndSelect
Loop
PlayMacro 1 "Replace100"
Find "\0\"
IfNotFound
ExitLoop
EndIf
Key HOME
IfColNumGt 1
Key HOME
EndIf
PlayMacro 1 "CountUp"
EndLoop
Top
ClearClipboard
Clipboard 0

Note: I have written the macros directly in the edit field in the browser window and so I have not tested it.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4056
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Find/Replace with counting function question...

Postby officerspock » Wed Jul 11, 2007 2:52 pm

Mofi,

Thank you thank you thank you!

I read over your CountUp macro but didn't have enough understanding about UE's Macro language to do the whole "call 2 macros from a macro" step.

Cheers from the USA!
User avatar
officerspock
Newbie
 
Posts: 2
Joined: Mon Jul 09, 2007 11:00 pm


Return to Macros