Assistance with a macro please....

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
grindy
Posts: 20
Joined: Mon Aug 29, 2005 6:10 pm

Assistance with a macro please....

Post by grindy »

Hello all,

I have an application that creates large text files. I want to create a macro that will run thru one of these large documents, find lines with a specific word in it, CUT that line and paste it into a second (initially blank) document, and then go back to the first document and do that again until all lines with that word in it are contained in the second document.

Take for instance the text below, which would represent the initial document:

Single line here with the word Jupiter in it.
Another line here with the word Jupiter in it.
Single line here with the word Mars in it.
Another line here with the word Pluto in it.
Single line here with the word Jupiter in it.
Another line here with the word Fred in it.
Single line here with the word Martha in it.
Single line here with the word Jupiter in it.

Let's say that I want to find all lines with the word Jupiter in it, and cut that entire line to my second document. Here's what I've tried that doesn't work.

I began a new macro recording
Beginning at the top of the document I do a search for Jupiter
It immediatly finds the first occurrance
I hit the Home key to go to the beginning of the line
I hit the down arrow key while simultaneously holding the shift key, which "selects" the line.
I hit the CUT button
I switch to the second document and hit PASTE
I then go back to the initial document and end the macro, naming it and also checking the repeat to tell it to keep repeating that to the end of the initial document.

When I run the macro, it "acts" like it's doing what I want (I see it quickly moving thru the main document), but nothing appears in the second document.

Using TextPad 7.5.1 btw.

Any help here would be greatly appreciated.
Thanks .....
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

It's much easier than that.

Mark all the lines containing Jupiter:
Search | Find... (<F5>):
Find what: Jupiter

Mark All
Cut the marked lines:
Edit | Cut Other | Bookmarked Lines

Then paste them into the other document.
grindy
Posts: 20
Joined: Mon Aug 29, 2005 6:10 pm

Post by grindy »

Thank you very much, ben_josephs .
I'd not used the bookmark/copy option before, and that works splendidly.
:D
grindy
Posts: 20
Joined: Mon Aug 29, 2005 6:10 pm

Post by grindy »

I just used this tonight for a different search, and it works perfectly...

Just wanted to thank you again, ben_josephs ! :)
Post Reply