Page 1 of 1

Count footnotes?

Posted: 2014-12-25 21:11:06
by PostGradDad
Does anyone know if there is a way to count the number of footnotes in a document, please?

Re: Count footnotes?

Posted: 2014-12-30 04:07:04
by Þorvarður
PostGradDad wrote:Does anyone know if there is a way to count the number of footnotes in a document, please?
Here is a macro that will count the number of footnotes in your document.

Code: Select all

### How many footnotes are in my document? ###
# Based on the macro "Select Note References in Body" (by Kino?)

Require Application Version 3.1
$doc = Document.active
if $doc == undefined
	exit
end

$notes = $doc.allNotes
if ! $notes.count
	Exit 'No note found, exit...'
end

$text = $doc.text

$noteRefsInBody = Array.new

$count = 0
foreach $note in $notes
	$count = $count+1
end

If $count >1
	$texti1 = "In your document are "
	$texti2 = " footnotes."
		else
	$texti1 = "In your document is "
	$texti2 = " footnote."
end

$count = $count & $texti2

Prompt $texti1 & $count

### end of macro ###

Re: Count footnotes?

Posted: 2014-12-30 16:52:54
by PostGradDad
Awesome! Many thanks, Þorvarður.

Re: Count footnotes?

Posted: 2015-01-01 06:06:29
by phspaelti
While Þorvarður's will work fine, note that all the information required is contained in the single variable $doc.allNotes.count, so the following macro would be sufficient:

Code: Select all

$doc = Document.active
prompt $doc.allNotes.count
:wink:

Re: Count footnotes?

Posted: 2015-01-03 23:37:12
by Þorvarður
phspaelti wrote:all the information required is contained in the single variable $doc.allNotes.count
This is really nice. Thank you, Philip. Where would we be without you? :D

Happy New Year!