I need a small macro. Basically an automated version of the search where you can list all lines containing the searched string and copy all of them to clipboard.
Right now I'm doing this... it works but it takes damn long.. there must be away to do this faster...
Your largely doing what I would do. The one thing I might do different is do an expression search.This would be better because UE's kernel would be highlighting everything we want to append into the clipboard as part of the search. This would elminate a few lines of macro code from your loop processing. In the example below, we are searching for lines containg string "asdf" (no quotes).
The macro places a blank line at end of file so we have that as an anchor. Clears clipboard, searches file in a loop, appending results into clipboard. When were done we delete that blank line we inserted. Clipboard contains what you want.
The macro itself should have a check in the macro attribute "continue if find with replace not found". This will eliminate your error dialog box at EOF.
Does this work any faster?
Bottom
Key END
"
"
Top
ClearClipboard
Loop
Find RegExp "%*asdf*^p"
IfFound
CopyAppend
Else
ExitLoop
EndIf
EndLoop
Bottom
Key END
Key BACKSPACE
I'm trying to create a macro that finds all occurrences of a particular string in a file and copies just those lines to a new file.
I used macro recording to capture the exact steps I do manually but the function does NOT record the "Clipboard" button press in the "Lines containing find string" window (see the resulting captured macro listing below).
List Lines Containing String is a find option which cannot be used from a macro because it requires user interaction. The macro solution is to use a loop with CopyAppend command. The following macro runs always from top of the file and needs the macro property Continue if a Find with Replace not found or Continue if search string not found enabled.
A variant of above which copies only the found string to clipboard with an additional CR/LF (or just CR or LF according to file type and edit mode) to get just a list of found strings. That makes only sense for a regular expression search. Unfortunately it is not possible to simply append a string to clipboard in the macro environment. (Scripts can do it.) So always the line termination must be inserted and cut with append to the clipboard.
A third version is like above. It just copies the found strings, but without appending immediately the line terminations. So in the new file there are lots of found strings on one single line and nearly the same regular expression as used before is used now to insert the line terminations. The example code below is for the UltraEdit regular expression engine for DOS files. For Unix or Perl regexp use just () instead of ^(^) and \1 instead of ^1. For UNIX files not temporarily convert to DOS on load use ^n (UE regexp) respectively \n (Unix/Perl regexp).
InsertMode
ColumnModeOff
HexOff UnixReOff
Top
Clipboard 9
ClearClipboard
Loop
Find RegExp "enter regex search string here"
IfFound
CopyAppend
Else
ExitLoop
EndIf
EndLoop
NewFile
Paste
Top
Find RegExp "^(enter regex search string here again^)"
Replace All "^1^p"
ClearClipboard
Clipboard 0
Best regards from an UC/UE/UES for Windows user from Austria