Adding section break via macro

Get help using and writing Nisus Writer Pro macros.
Post Reply
xiamenese
Posts: 421
Joined: 2006-12-08 00:46:44
Location: London or Exeter, UK

Adding section break via macro

Post by xiamenese » 2013-07-03 18:20:04

I am trying to create a macro which will take a string in a file exported from Scrivener:

Code: Select all

‡‡‡‡‡
and replace it with a <Section Break : Next Page>.

When I use Find and Replace, enter the appropriate string in the Find box and put the appropriate command from the menu in the Replace box,
Nisus Writer ProScreenSnapz001.jpg
Nisus Writer ProScreenSnapz001.jpg (46.72 KiB) Viewed 3556 times
then click "Replace All" it does just what I want.

If I choose "Macroize", it puts the following commands into the macro — copying it to the clipboard reveals this:

Code: Select all

Find and Replace '‡‡‡‡‡
', '', 'aU'
When I run that, what I get is <Section Break [No page break]> Can someone tell me how can I make it so that the Macro gives me a page break.

Thanks
Mark

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

Re: Adding section break via macro

Post by martin » 2013-07-03 23:09:21

Offhand I'm not sure why the macroized version isn't working. It probably has something to do with the way section break characters rely on a hidden attribute to enforce their next page, same page, odd page, etc, status. We'll have to take a look.

In the meantime, the most direct workaround is something like this:

Code: Select all

$findWhat = '‡‡‡‡‡
'

Select Document Start
While Find Next $findWhat
	Menu 'Insert:Section Break:Next Page'
End

Groucho
Posts: 496
Joined: 2007-03-03 09:55:06
Location: Europe

Re: Adding section break via macro

Post by Groucho » 2013-07-04 05:50:39

Hello, Mark.

I wrote this macro years ago. It still works nicely. Last time I used it was yesterday. You can substitute any kind of section break for any placeholder text. Just run it.

Greetings, Henry.
Split into Sections.nwm
(31.5 KiB) Downloaded 208 times

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

Re: Adding section break via macro

Post by martin » 2013-07-05 13:30:25

That's a handy macro Henry, thanks for sharing it.

One irrelevant improvement you could make to reduce the code is changing this:

Code: Select all

While Find $tag, 'E'
	if $break == "Next Page"
	Insert:Section Break:Next Page
	elsif $break == "Odd Page"
	Insert:Section Break:Odd Page
	elsif $break == "Even Page"
	Insert:Section Break:Even Page
	elsif $break == "Same Page"
	Insert:Section Break:Same Page
	end
end
To construct the menu path directly using the user's chosen section break type name:

Code: Select all

$menuPath = "Insert:Section Break:$break"
While Find $tag, 'E'
	Menu $menuPath
end

Groucho
Posts: 496
Joined: 2007-03-03 09:55:06
Location: Europe

Re: Adding section break via macro

Post by Groucho » 2013-07-05 21:43:04

Great help, Martin, thanks. About the menu path, that was something I tried to do but I lacked the skills. I will change the macro.

Greetings, Henry.

Post Reply