Page 1 of 1

numbering macro problems

Posted: Fri Mar 10, 2023 11:03 pm
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

Re: numbering macro problems

Posted: Mon Mar 13, 2023 5:07 pm
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

Re: numbering macro problems

Posted: Mon Mar 13, 2023 7:02 pm
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.

Re: numbering macro problems

Posted: Mon Mar 13, 2023 8:41 pm
by jazzastronomer
I can also replicate this issue with Windows 10 and Textpad 8.16.0.

Re: numbering macro problems

Posted: Sun Apr 02, 2023 10:05 am
by bbadmin
This is fixed in TextPad 9.1. The scope of the macro must be set to Selection for it to work.

Re: numbering macro problems

Posted: Sun Apr 02, 2023 7:57 pm
by jazzastronomer
I can confirm that my little macro is working in Textpad 9.2.0 64bit Windows 11

many thanks

Re: numbering macro problems

Posted: Mon Apr 03, 2023 9:53 am
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.

Re: numbering macro problems

Posted: Mon Apr 03, 2023 12:10 pm
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).