calling macro within macro broke in 1.3

Get help using and writing Nisus Writer Pro macros.
Post Reply
credneb
Posts: 140
Joined: 2007-03-28 07:30:34

calling macro within macro broke in 1.3

Post by credneb » 2009-07-01 09:53:58

First, thanks for v1.3. I've already noticed some nice improvements.

As part of my suite of glossary related macros, one I called "Load List of Glossary Files" is long and is called from several other macros.

Basically all it does is get and filter all glossary files in the glossary folder and either automatically opens the glossary of interest or presents a prompt allowing the user to select a glossary. After working out the kinks, it has worked without fail until this morning when I upgraded to 1.3.

What the macro now does is open itself, resulting in the glossary entries being entered in the macro file.

However, if I paste the body of my Load List macro into the glossary editing macro (replacing the easy to read single line), everything works as it does in 1.2. This obviously makes maintaining and improving the macros significantly more difficult.

In this particular instance the Load List macro extracts the file path and file extension and goes from there. In 1.2 the filepath and extension were correctly read as those for the active document (the document being edited, which may be the glossary file). In 1.3, however, the nested macro gets the extension for the *macro* file, i.e., it seems to be making itself the active document.

What happened? Was a macro calling another macro always illegal but worked anyway?
Was this change intentional or accidental?

Thanks for your help.

Cliff

credneb
Posts: 140
Joined: 2007-03-28 07:30:34

Re: calling macro within macro broke in 1.3

Post by credneb » 2009-07-01 10:50:33

Further to my previous post, it seems that calling macro2 from macro1 causes macro2 to open for editing and not execute.

Now obviated by the new operation of the Select Paragraph command, I used the Select Current Paragraph macro:

Code: Select all

Select Previous Paragraph
Select Next Paragraph
in a macro such as

Code: Select all

Select Current Paragraph
Bold
Select End
In 1.3 Select Current Paragaph opens itself when called and execution then stops. This seems odd.

User avatar
martin
Official Nisus Person
Posts: 4251
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: calling macro within macro broke in 1.3

Post by martin » 2009-07-01 11:30:26

Calling another macro was always legal and supported. I just tried your example macros, which work together to make the whole paragraph bold, and didn't have any problems. I tried running the second macro using Run Selection As Macro, choosing the macro from the menu directly, and assigning/triggering a keyboard shortcut for the macro- none of these caused the "Select Current Paragraph" macro file to open.

Does the problem occur for you if you choose the macro directly from the menu using the mouse? Can you send me your macro files using the menu Help > Send Feedback? Thanks.

credneb
Posts: 140
Joined: 2007-03-28 07:30:34

Re: calling macro within macro broke in 1.3

Post by credneb » 2009-07-01 12:17:24

I just tried them again, and the same problem occurs whether the macro is called from the menu using the mouse or using a keyboard shortcut as usual.

I just sent the four macro files in a .zip to feedback.

This is on a 2-mth old MBPro with 10.5.7.

User avatar
martin
Official Nisus Person
Posts: 4251
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: calling macro within macro broke in 1.3

Post by martin » 2009-07-01 23:02:43

Kino has sussed out the problem: if the secondary macro file appears in your Document Manager somehow (eg: even the "Currently Open" group) and you have extensions hidden, then there exists a menu with a path like:

:File:Open From Document Manager:Recently Opened:Select Current Paragraph

This makes the macro command "Select Current Paragraph" ambiguous- does it mean to trigger that "open" menu, or to run the sub-macro? In most cases the latter behavior is desired. This is something we'll have to change, but you can work around it by doing one of the following:

1. Turning on "show file extensions" for your Document Manager (DM).
2. Removing any DM groups that would unintentionally show macro files.
3. Use a full/partial path for the macro command, eg: ":Macro:Select Current Paragraph"

credneb
Posts: 140
Joined: 2007-03-28 07:30:34

Re: calling macro within macro broke in 1.3

Post by credneb » 2009-07-02 08:38:22

Ah, so some mystery is cleared up.

However, it seems more complicated than just
1. Turning on "show file extensions" for your Document Manager (DM).

I turned this on by unchecking the checkbox in the DM preference panel, and the problem repeated.

Looking at the files in the Finder, the extension was not shown. Setting the Finder to show the extension solved the problem.

It doesn't seem to matter if DM shows or does not show the extension if the Finder does not show it. I hope you can reproduce this.

I also discovered by examining DM while running macros that NWP happily looks into the backup folder and runs the macro from there if it doesn't find it in the main Macro folder. (I had deleted the Select Current Paragraph macro from the Macro folder, but another (unmodified) macro called it, so NWP fetched it from the backup folder.) I would have expected an error.

credneb
Posts: 140
Joined: 2007-03-28 07:30:34

Re: calling macro within macro broke in 1.3

Post by credneb » 2009-07-02 09:27:51

There must be even more going on somewhere. With additional fiddling, not changing how macro2 is called and variously turning extensions on and off in the Finder and DM, the problem comes and goes. Right now it's gone and extensions aren't shown in Finder or DM. This is before and after rebooting NWP.

Transient seems the best description.

User avatar
martin
Official Nisus Person
Posts: 4251
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: calling macro within macro broke in 1.3

Post by martin » 2009-07-02 11:28:52

I actually don't believe the setting for "show extensions" in the Finder will affect this at all.

I think the randomness you are seeing is whether or not the DM menus have been refreshed yet or not. Those menus are loaded/updated lazily (generally only when they are shown, but possibly at other times), so that can affect whether the bug triggers or not. Also, changing whether the DM shows extensions won't have any effect until the relevant menus are rebuilt.

Also keep in mind that the file may appear in multiple groups automatically, eg: "Recently Saved", "Recently Opened", "Backups", etc.

The sure way to beat this problem is to use an explicit path, eg:

Code: Select all

Menu ":Macros:Select Current Paragraph"

User avatar
martin
Official Nisus Person
Posts: 4251
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: calling macro within macro broke in 1.3

Post by martin » 2009-07-02 11:31:54

credneb wrote:I also discovered by examining DM while running macros that NWP happily looks into the backup folder and runs the macro from there if it doesn't find it in the main Macro folder. (I had deleted the Select Current Paragraph macro from the Macro folder, but another (unmodified) macro called it, so NWP fetched it from the backup folder.) I would have expected an error.
It was changed in NWP 1.3 so that macros in the main DM folder are loaded/displayed in the Macros menu. However, I would agree that macro files in the Backups subfolder should be excluded. I'll file a bug, thanks.

Post Reply