Reply to topic  [ 5 posts ] 
Adding section break via macro 
Author Message

Joined: 2006-12-08 00:46:44
Posts: 417
Location: London or Exeter, UK
I am trying to create a macro which will take a string in a file exported from Scrivener:
Code:
‡‡‡‡‡

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,
Attachment:
Nisus Writer ProScreenSnapz001.jpg
Nisus Writer ProScreenSnapz001.jpg [ 46.72 KiB | Viewed 3159 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:
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


2013-07-03 18:20:04
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
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:
$findWhat = '‡‡‡‡‡
'

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


2013-07-03 23:09:21
Profile WWW

Joined: 2007-03-03 09:55:06
Posts: 494
Location: Europe
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.

Attachment:
Split into Sections.nwm [31.5 KiB]
Downloaded 204 times


2013-07-04 05:50:39
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
That's a handy macro Henry, thanks for sharing it.

One irrelevant improvement you could make to reduce the code is changing this:
Code:
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:
$menuPath = "Insert:Section Break:$break"
While Find $tag, 'E'
   Menu $menuPath
end


2013-07-05 13:30:25
Profile WWW

Joined: 2007-03-03 09:55:06
Posts: 494
Location: Europe
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.


2013-07-05 21:43:04
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software