Works in 10.5; -1719 Error in 10.7
Works in 10.5; -1719 Error in 10.7
- Subject: Works in 10.5; -1719 Error in 10.7
- From: Rick Gordon <email@hidden>
- Date: Thu, 03 Nov 2011 15:07:56 -0700
The following script works when run from Script Editor in 10.5.8, but apparently errors in 10.7, which I don't have installed. Someone reports that he gets a -1719 error when running from Script Editor in 10.7.2. I'm suspecting that it may relate to a difference in the handling of references. Does anyone have some input?
The script should renumber all of the playOrder="<SOME NUMBER>", so that they start from 1 and increment upward.
--
(* AppleScript to sequence playOrder values in an NCX file opened into TextEdit incrementally from 1. Does NOT save the file. Check and manually save.
Copyright ©2011 by Rick Gordon. Use it freely with credit to me. *)
set vOldValues to {}
set vNewValues to {}
tell application "TextEdit"
try
tell document 1
set vList to a reference to (paragraphs where it contains "PlayOrder")
set vLength to count items of vList
repeat with i from 1 to vLength
tell item i of vList
set vPlayOrderWord to (a reference to (some word where it is "PlayOrder"))
set vPlayOrderValue to (a reference to (word after word after vPlayOrderWord))
set end of vOldValues to contents of vPlayOrderValue
set contents of vPlayOrderValue to i as text
set end of vNewValues to contents of vPlayOrderValue
end tell
end repeat
end tell
on error
return vOldValues & return & vNewValues
end try
return vOldValues & return & vNewValues
end tell
--
--SAMPLE SOURCE NCX CONTENT, TO BE PASTED INTO OR OPENED IN TEXTEDIT:
<?xml version="1.0"?>
<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN" "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
<head>
<meta name="dtb:uid" content="9780936070544" />
<meta name="dtb:depth" content="4" />
<meta name="dtb:totalPageCount" content="0" />
<meta name="dtb:maxPageNumber" content="0" />
</head>
<docTitle>
<text>My Book Title</text>
</docTitle>
<navMap>
<navPoint id="navpoint" playOrder="4"><navLabel><text>Tips on Using This Book</text></navLabel><content src="0-FM00-TipsOnUsingThisBook.xhtml" /></navPoint>
<navPoint id="navpoint-1" playOrder="5"><navLabel><text>What's New in This Edition</text></navLabel><content src="0-FM0-WhatsNew.xhtml" /></navPoint>
<navPoint id="navpoint-2" playOrder="8"><navLabel><text>Title Page</text></navLabel><content src="0-FM1-TitlePage.xhtml" /></navPoint>
<navPoint id="navpoint-3" playOrder="9"><navLabel><text>Copyright Page</text></navLabel><content src="0-FM2-CopyrightPage.xhtml" /></navPoint>
<navPoint id="navpoint-4" playOrder="10"><navLabel><text>Preface</text></navLabel><content src="0-FM3-Preface.xhtml" /></navPoint>
<navPoint id="navpoint-5" playOrder="13"><navLabel><text>Introduction </text></navLabel><content src="0-FM4-Introduction.xhtml" /></navPoint>
<navPoint id="navpoint-6" playOrder="14"><navLabel><text>Origin of the Marathon</text></navLabel><content src="00-History.xhtml#toc-anchor" /></navPoint>
<navPoint id="navpoint-7" playOrder="15"><navLabel><text>I: TRAINING</text></navLabel><content src="01p1-Getting_Started.xhtml#toc-anchor-1" />
<navPoint id="navpoint-8" playOrder="19"><navLabel><text>1: Getting Started</text></navLabel><content src="01p1-Getting_Started.xhtml#toc-anchor-2" /></navPoint>
<navPoint id="navpoint-9" playOrder="20"><navLabel><text>2: The Long Run</text></navLabel><content src="02-The_Long_Run.xhtml#toc-anchor" /></navPoint>
<navPoint id="navpoint-10" playOrder="21"><navLabel><text>3: The Galloway Run-Walk-Run Method</text></navLabel><content src="03-Walk_Breaks.xhtml#toc-anchor" /></navPoint>
<navPoint id="navpoint-11" playOrder="22"><navLabel><text>4: Running Form</text></navLabel><content src="04-Running_Form.xhtml#toc-anchor" /></navPoint>
<navPoint id="navpoint-12" playOrder="25"><navLabel><text>5: Cross Training</text></navLabel><content src="05-Cross_Training.xhtml#toc-anchor" /></navPoint>
<navPoint id="navpoint-13" playOrder="26"><navLabel><text>6: The Programs</text></navLabel><content src="06-The_Programs.xhtml#toc-anchor" /></navPoint>
</navPoint>
</navMap>
</ncx>
--
___________________________________________________
RICK GORDON
EMERALD VALLEY GRAPHICS AND CONSULTING
___________________________________________________
WWW: http://www.shelterpub.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden