Page 1 of 1

How to script Table Delete Rows?

Posted: 2012-10-16 11:10:01
by ssampler
I'm on OS X 10.6.8. NWP 2.04
I've written several Apple scripts to manipulate tables, so that I can call them by name with LaunchBar. I'm stumped on how to delete selected rows in a table. In the manual, P. 418, are the examples:

Code: Select all

Do Menu Macro with macro "FormatFontTimes"
Do Menu Macro with macro "FontBold"
By analogy with these, either of:

Code: Select all

Do Menu Macro with macro "TableDeleteRows"
Do Menu Macro with macro "DeleteRows"
should work, but neither does, stopping with an error: "Unknown Menu Item Path"

I notice one difference between these and the previous two : "Rows", a choice in the Table Delete sub-menu, is also a choice in the Table Select sub-menu. In the first two examples, on the other hand, "Bold" and "Times" do not appear in any other sub-menu. In fact,

Code: Select all

Do Menu Macro with macro "Times"
Do Menu Macro with macro "Bold"
both work, because they define unique sub-menu items.

Steve

Re: How to script Table Delete Rows?

Posted: 2012-10-17 14:50:36
by martin
Hi Steve,

When working with ambiguous command names, you'll need to specify a full (or partial) menu path, using a colon character as a path separator. So instead of just "Rows" you'll need "Delete:Rows" or ":Table:Delete:Rows".

Putting that all together in an AppleScript would look like:

Code: Select all

tell application "Nisus Writer Pro"
	Do Menu Macro with macro ":Table:Delete:Rows"
end tell
I hope that does the trick— let us know if you have any other questions.

Re: How to script Table Delete Rows?

Posted: 2012-10-17 19:45:20
by ssampler
Thanks, Martin!

The solution seemed familiar, and it was, once: http://www.nisus.com/forum/viewtopic.ph ... 9722#p9722. I also see the example on page 402 of the manual. The initial colon doesn't appear to be necessary.

I appreciate NWP tables more than ever now. They are perfect for logging data analyses, and "Merge Cells" (also scripted) gives me room for long comments.

Steve

Re: How to script Table Delete Rows?

Posted: 2012-10-17 20:31:12
by martin
Happy to help– I'm glad that did the trick, and to hear you're making good use of tables and macros!