2009-06-23

Story Has Notes

/*
Determine if there are notes in a story.
*/
//
#target incopy
var aStory = app.documents[0].stories[0] ;
if ( storyNotesExists ( aStory ) )
alert ('that story has notes' ) ;

//
function storyNotesExists ( storyRef ) {
//----------------------------------------------------------------------
//-- S T O R Y N O T E S E X I S T S
//----------------------------------------------------------------------
//-- Generic: Yes for Adobe InDesign or Adobe InCopy CS2, CS3, CS4
//----------------------------------------------------------------------
//-- Purpose: To return true or false after determining if notes exist
//-- within the passed story.
//-- This is useful if you are cleaning up stories and placing
//-- undesirable text within a note. If is extremely safe to assume
//-- that any story with notes has already been edited and/or cleaned.
//----------------------------------------------------------------------
//-- Arguments: 1
//-- storyRef: A reference to a story in Adobe InDesign or Adobe InCopy
//-- this might be in the form of many things including:
//-- app.documents[0].stories[0]
//-- app.selectionp[0].parentStory
//-------------------------------------------------------------------------
//-- Calls: Nothing
//-------------------------------------------------------------------------
//-- Returns: True or false.
//-------------------------------------------------------------------------
//-- Written by: Jon S. Winters on 2009.06.20
//-- Edited: 2009.06.23
//-- eps@electronicpublishingsupport.com
//-------------------------------------------------------------------------
try {
//-- See if passed story reference has a notes collection with more
//-- zero items. If so, return true. If not, return false.
return ( storyRef.notes.length > 0 ) ;
}
catch (err) {
//-- If anything caused an error, return false. This protects us when
//-- the function was called with something other than a story.
return false ;
}
}
//

No comments:

Post a Comment