numbering macro problems

General questions about using TextPad

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

Post Reply
jazzastronomer
Posts: 34
Joined: Sat Nov 03, 2007 3:04 am

numbering macro problems

Post by jazzastronomer »

I want to add an index number to a list.
So this:

Code: Select all

Apples
Bananas
Cherries
becomes this:

Code: Select all

1.  Apples
2.  Bananas
3.  Cherries
I used Replace:
  • Find what = ^
  • Replace with = \i. (with 2 spaces after the period)
  • Regular expression = yes
  • Scope = Selected text (must select text before running macro)
  • button "Replace All"
Here is the code from the macro editor:

Code: Select all

# SearchReplace
Replace = "^", "\\i.  ", RegExp, InSelection
DoReplaceAll
Here is the issue:
  • If I run the regex in the regex input box, the regex works as expected.
  • If I save the regex as a macro and then run the macro from the macro menu, the selected text coloring just disappears with no numbers added.
  • If I run the saved macro from the macro editor, the macro works as expected.
I notice that when I initially bring up the macro editor, the validate button is greyed out. I can enable validation by making a change in the macro editor and then reverting it back. This seems like a bug.

My macro did validate. Though the text said "validated" I also got a yellow caution symbol, so I'm not sure which to believe. So why doesn't my saved macro run?

Thanks
Last edited by AmigoJack on Sat Mar 11, 2023 10:56 pm, edited 1 time in total.
Reason: more formatting
jazzastronomer
Posts: 34
Joined: Sat Nov 03, 2007 3:04 am

Re: numbering macro problems

Post by jazzastronomer »

Thanks for the editing, looks much better!

I am using 64 bit windows 11 and Textpad 9.1.0.

Can somebody replicate this issue?

Thanks
User avatar
bbadmin
Site Admin
Posts: 820
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Re: numbering macro problems

Post by bbadmin »

I copied and pasted your macro into the editor and saved it, and it works correctly from the menu.

The Validate button is disabled until you change a macro, because initially it must already be valid.

The exclamation mark icon on the message box will be corrected in the next release.
jazzastronomer
Posts: 34
Joined: Sat Nov 03, 2007 3:04 am

Re: numbering macro problems

Post by jazzastronomer »

I can also replicate this issue with Windows 10 and Textpad 8.16.0.
User avatar
bbadmin
Site Admin
Posts: 820
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Re: numbering macro problems

Post by bbadmin »

This is fixed in TextPad 9.1. The scope of the macro must be set to Selection for it to work.
jazzastronomer
Posts: 34
Joined: Sat Nov 03, 2007 3:04 am

Re: numbering macro problems

Post by jazzastronomer »

I can confirm that my little macro is working in Textpad 9.2.0 64bit Windows 11

many thanks
BlessingLinys
Posts: 1
Joined: Mon Apr 03, 2023 9:38 am

Re: numbering macro problems

Post by BlessingLinys »

It is possible that your macro has a syntax or typographical error that causes it not to work correctly when run from the macro menu. You can try checking your macro carefully for errors. Perhaps your program or programming language doesn't support regular expressions or doesn't support certain functions you use in your macro. In this case, you need to make sure that you are using the correct syntax for your program or programming language. Your macro may not have the correct permissions to run. In this case, you need to make sure that you have the proper permissions to run macros in your program.
User avatar
AmigoJack
Posts: 500
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Re: numbering macro problems

Post by AmigoJack »

BlessingLinys wrote: Mon Apr 03, 2023 9:53 amPerhaps your program or programming language doesn't support regular expressions or doesn't support certain functions you use in your macro. In this case, you need to make sure that you are using the correct syntax for your program or programming language. Your macro may not have the correct permissions to run. In this case, you need to make sure that you have the proper permissions to run macros in your program.
All this would apply to tools (running an external program), not macros (running TextPad actions).
Post Reply