by Mofi » Thu Oct 28, 2004 9:48 am
Here is a macro, which should be faster because no window/document swapping is used.
Make sure, that only the two source files are open in UE.
The macro copies the whole content of the active file (source 1) to a new file, checks if last line is an empty line and set a bookmark to the end of the content of the first file (bookmark 2 on first line of file 2).
Then it copies the whole content of the second file to the new file, checks if last line is an empty line, jumps to top of the new file and sets a bookmark (bookmark 1 on the actual line of file 1).
In the loop:
jump to bookmark 2 (actual line of second file),
remove the bookmark,
cut the line content,
delete the unwanted line break,
set new bookmark 2,
jump to bookmark 1 (actual line of file 1),
go to end of line,
insert a space and the cutted line of file 2,
remove bookmark 1
go to next line
set bookmark 1
It works also on files with different numbers of lines, because it stops, if reached the end of file, independent if file 1 or file 2 have more lines than the other file.
If you want to see how it works, cut the whole loop (from Loop to EndLoop to a second macro and set loop count to 1 (Loop 1). Now run first the init macro to get the initial status of the new file. Then run the loop macro manually a few times to see how it works.
Tip: First copy the macro from the browser to a text window in UltraEdit and trim trailing spaces after copying. Then copy it to the macro edit window.
Here is the line merge macro:
InsertMode
ColumnModeOff
HexOff
UnixReOff
SelectAll
StartSelect
Copy
EndSelect
NewFile
Paste
IfColNum 1
Else
"
"
EndIf
ToggleBookmark
PreviousWindow
SelectAll
StartSelect
Copy
EndSelect
NextWindow
Paste
IfColNum 1
Else
"
"
EndIf
Top
ToggleBookmark
Loop
GotoBookMark
ToggleBookmark
IfEof
ExitLoop
EndIf
StartSelect
Key END
Cut
Key DEL
ToggleBookmark
GotoBookMark
IfEof
Paste
"
"
ExitLoop
EndIf
Key END
" "
Paste
ToggleBookmark
Key HOME
Key DOWN ARROW
ToggleBookmark
EndLoop
GotoBookMark
ToggleBookmark
Top