🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #17232

Re: [AS]How to make an index entry/page reference

#17232
From: Olav Kvern
Date: Thu, 26 Jun 2003 08:02
84 lines
3518 bytes
Eric--

Sorry about that--what you need to know is that the first argument of "make" for an index topic is *required*--and it's very difficult to see this in the AppleScript dictionary browser. So the line should look something like this:



--Given an index "myIndex"
tell myIndex
    set myTopic to make topic with data{"Topic Name"}
end tell




Next, making the page reference has *two* required parameters, but you use the "with properties" construction:



--Given a topic "myTopic", a reference to a 
--story "myStory", and an index "myOffset"
--which sets the position in the story at which you want to
--place the index entry marker.
tell myTopic
    set myPageReference to make page reference with properties{parent story:myStory, storyOffset:myOffset}
end tell




Here's a more complete example:



--Create an example index
set myString to "Marshal:" & tab & "Year Appointed:" & return & �
	"Pierre Francois Charles Augereau" & tab & "1804" & return & �
	"Jean Baptiste Bernadotte" & tab & "1804" & return & �
	"Louis Alexandre Berthier" & tab & "1804" & return & �
	"Jean Baptiste Bessieres" & tab & "1804" & return & �
	"Guillaume Brune" & tab & "1804" & return & �
	"Louis-Nicholas Davout" & tab & "1804" & return & �
	"Gouvion St. Cyr" & tab & "1812"
tell application "InDesign 2.0.2"
	set myDocument to make document
	tell myDocument
		set myIndex to make index
	end tell
	--Set up the example text on page 1
	tell page 1 of myDocument
		set myX1 to margin left of margin preferences
		set myY1 to margin top of margin preferences
		set myX2 to (page width of document preferences of myDocument) - (margin left of margin preferences)
		set myY2 to (page height of document preferences of myDocument) - (margin bottom of margin preferences)
		set myTextFrame to make text frame with properties {geometric bounds:{myY1, myX1, myY2, myX2}, contents:myString}
	end tell
	set myOffset to index of paragraph 3 of story 1 of document 1
	tell myIndex
		--create a topic
		set myTopicName to "Bernadotte, Jean Baptiste"
		--Add the topic to the index if it does not already exist.
		try
			set myTopic to index topic myTopicName of myIndex
		on error
			set myTopic to make topic with data {myTopicName}
		end try
		--Add a page reference to the topic.
		tell myTopic
			--I'm not having any luck getting the subtopic to stick to the page reference--
			--but here's what it would look like if it did.
			--set mySubtopic to make subtopic with properties {name:"Jean Baptiste"}
			--make a page reference
			set myPageReference to make page reference with properties {parent story:story 1 of myDocument, story offset:myOffset}
		end tell
	end tell
end tell




Hope this helps!

Thanks,

Ole
Technical Details
Message-ID: <1de9aedc.2@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <1de9aedc.-1@WebX.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f939a,16d152d745c9958c
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-06-26 01:07:35 PST
From: "Olav Kvern" <okvern@adobe.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: [AS]How to make an index entry/page reference
Message-ID: <1de9aedc.2@WebX.la2eafNXanI>
Date: Thu, 26 Jun 2003 01:02:57 -0700
References: <1de9aedc.-1@WebX.la2eafNXanI>
Lines: 83
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit