A quick way to count page breaks.

Get help using and writing Nisus Writer Pro macros.
Post Reply
User avatar
loulesko
Posts: 89
Joined: 2008-01-20 11:08:35
Location: California
Contact:

A quick way to count page breaks.

Post by loulesko » 2009-12-15 01:38:39

Hey there, can anyone give me a quick way to count the number of page breaks in a document. Preferably without using the Find All command, but if that's the only way no problem.

Thanks
Lou

Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: A quick way to count page breaks.

Post by Kino » 2009-12-15 02:34:22

You could check for all characters in the document but that is much more time-consuming. So you’d better use Find All.

Page/Section break is represented by \f in PowerFind Pro mode. To exclude false page breaks in note area, you have to specify -am as where argument.

Code: Select all

$n = Find All '\f', 'E', '-am'
exit $n
Or you don’t want breaks to be selected? If so, use the following.

Code: Select all

 $doc = Document.active
$sels = $doc.text.findAll '\f', 'E', '-am'
exit $sels.count

User avatar
loulesko
Posts: 89
Joined: 2008-01-20 11:08:35
Location: California
Contact:

Re: A quick way to count page breaks.

Post by loulesko » 2009-12-15 09:15:05

Brilliant Kino.

I noticed that you have contributed a lot of awesome macros to the macro repository. Thanks for all your fantastic work, generous people like you, make life for people like me easier. Your work is very much appreciated.

Lou

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

Re: A quick way to count page breaks.

Post by martin » 2009-12-15 14:46:47

Kino is indeed a generous NWP macro superstar! We're all very lucky to have him as a Nisus user :)

User avatar
loulesko
Posts: 89
Joined: 2008-01-20 11:08:35
Location: California
Contact:

Re: A quick way to count page breaks.

Post by loulesko » 2009-12-27 12:10:53

Kino,

Can you tell me where you found the documentation for the where argument in your find statement. I looked everywhere for it and I can't find it and I'd like to learn more about it.

thanks
Lou

Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: A quick way to count page breaks.

Post by Kino » 2009-12-27 16:32:25

loulesko wrote:Can you tell me where you found the documentation for the where argument in your find statement.
Open Nisus Macro Reference.zrtf and search for “The where argument” which will be found in Find and Replace section under COMMANDS.

User avatar
loulesko
Posts: 89
Joined: 2008-01-20 11:08:35
Location: California
Contact:

Re: A quick way to count page breaks.

Post by loulesko » 2009-12-27 19:00:28

Thanks, I had an older version of the macro reference.

Lou

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

Re: A quick way to count page breaks.

Post by martin » 2009-12-28 16:10:27

One can always view the current Macro Reference by using the menu Help > Macro Language Reference from within NWP.

Post Reply