Search/Replace autoupdate during macro execution?

General questions about using TextPad

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

Post Reply
Lostgallifreyan
Posts: 25
Joined: Mon Feb 14, 2005 10:51 am

Search/Replace autoupdate during macro execution?

Post by Lostgallifreyan »

I have a sorted list, a forum archive with posts formatted to one line each, lines sorted by subject into blocks. I need to insert blank lines between blocks to ease further work. I'd have the source data file open, and also one empty document to receive data from it.

My idea is to build a macro that iterates through each subject. This would be especially useful as it would not need a prior sort; it would do that as part of this procedure.

[Begin macro]
Ctrl + Home
Select the first subject field plus one extra character using Find RegExp.
Exit Find, modify selection with Shift + Left arrow, so that next Find looks for the subject string rather than reusing the previous expression, which just found the subject field.
Second Find. (For actual found subject string).
Mark all found lines.
Cut bookmarked lines.
Ctrl + Tab to Destination document and paste, add newline.
Ctrl + Tab back to Source document.
[End macro]

Repeat to EOF.

This only works for the actual string found when building the macro. This is often useful as it makes things very fast when working with specific strings or RegExp's, as in the first Find in this idea, but in this case I don't want the string stored in the macro for the second find, only the means to find it (which is stored in the macro for the first Find). That way I can run the macro to sort by any subject regardless of what it might be.

As it is, I either have the explicit string stored, so it only matches that used when building the macro.
Or, I use a RegExp, but then it will match every subject field in the file, which is equally useless in this case.

Is there a way around this?

_________________________________________

As a related question, is there now (or intended) a way to write scripted macros, not just to build them by recording keypresses? That could be powerful, and might make it easier to solve things like this.
User avatar
s_reynisson
Posts: 939
Joined: Tue May 06, 2003 1:59 pm

Post by s_reynisson »

See my post here, should give you the info needed on TP and the find dialog usage in macros. Hope this helps.
About the "way to write scripted macros", Editable Macros are the Enhancement Suggestion for TP, see here.
Then I open up and see
the person fumbling here is me
a different way to be
Lostgallifreyan
Posts: 25
Joined: Mon Feb 14, 2005 10:51 am

Post by Lostgallifreyan »

Thankyou.
My searching wasn't too good today, I got too few results, or too many, either way I missed that thread.

And, it basically confirms what I said. :)

I knew about Ctrl + F, but the number of lines with a given subject string is arbitrary, so I never considered it as part of a strict repeating pattern. That said, this has focussed my thought on two patterns, one nested in the other, and a macro can always call another macro... I'll have a go at that tomorrow.

And I gave that poll my vote for full editable scripting. I devised my own notation for those so I could edit and rebuild, and if anyone wants it I can post it, but it's like painting by numbers, and having actual editable scripts that run directly would rock.

Although I gave it full backing, I still think the lack of these is not the most fundamental thing missing though, despite that 98% vote. On the strength of that, wouldn't binary edit get 100%?
User avatar
s_reynisson
Posts: 939
Joined: Tue May 06, 2003 1:59 pm

Post by s_reynisson »

Not quite, see jeffy's list of Relative rankings of every enhancement suggestion (scroll to bottom for the latest version). "binary file improvements" are at 8, the list is getting old but not much if anything has been added here in the forum since it was last posted.
Lostgallifreyan wrote:snip.. wouldn't binary edit get 100%?
Then I open up and see
the person fumbling here is me
a different way to be
Lostgallifreyan
Posts: 25
Joined: Mon Feb 14, 2005 10:51 am

Post by Lostgallifreyan »

thanks. I voted in that one now. :)

About the Ctrl + F, it won't do it, unless you prime it with the use of Ctrl + F before the macro is called. It's not enough to highlight the string, you must do at least one Ctrl + F before calling the repeating Ctrl + F macro. This pump priming trick will NOT work for the faster dialog-based mark all found lines, though. No matter how a string is found, the explicit string is stored in the dialog based Find tool, never the means of finding it.

An extended form of Ctrl + F would be cool, maybe Ctrl + Alt + F to find and mark all lines, but this isn't the answer. Once keyboard shortcuts get excessive, they start to conflict with stuff set up in the OS as a whole..



EDIT:
I've given up on this. It's like trying to cover a cricket pitch with a pair of jeans. The called macro won't always return to the start, in once instance it wrapped through the file to find an earlier line, in another call it would not, so I can't predict, so can't script anything at all. The calling macro wouldn't wait for the called macro, and the wrap failure was something I noticed while building the second attempt at the calling macro, so it's clearly not going to cut it. The one thing about trying to cover cricket pitches with pairs of jeans is: if you try hard enough, you tear the jeans. Once you see unpredictable tears developing, you know you're on a fools errand, even if it wasn't already obvious....

I've Lua-coded an answer for my immediate needs, but I'd like to do this stuff in TextPad if possible.

If scripted macros are to be developed, there are several things that need to be taken care of.

1. A timed wait instruction, to allow time for something outside the app's control.
2. An untimed wait instruction that is implicit whan a macro is called from another, so the called macro is allowed to complete.
3. A mode to store the RegExp and not the explicit found string, switchable on demand.

There are surely other needs that people more able than me can work out, but if this really is Priority Request Number One, it needs a LOT of thinking through, or a lot of people are going to be disappointed.

I'd be willing to pay again for a TextPad that could do this, and binary editing.

I'd pay double if it really did both of these things well, with syntax highlighting extended to edited bytes, and such...
Hint, and a bit of pleading thrown in for good measure.. :twisted:


My last thought on this:
Lua scripting built into TextPad.
User avatar
s_reynisson
Posts: 939
Joined: Tue May 06, 2003 1:59 pm

Post by s_reynisson »

I think it's fair to say that if we will see a new major TP version, it will support some scripting for macros. (Sheesh kebab! Now even I'm using "if" on a major release from Helios, zridling's posts must be getting to me - surely it must be time for a statement from Helios - yeah, I fully support your "bit of pleading thrown in for good measure"! ;))
Then I open up and see
the person fumbling here is me
a different way to be
Post Reply