Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running head - dictionary style 2

Status
Not open for further replies.

Galebovic

Technical User
May 26, 2004
5
YU
Is there an automatic way to make running header for a dictionary?
Please, do not dissapoint me by turning me to Ventura publisher... Please
 
If you have ID CS, the answer is probably yes. Define what kind of styling you're after, please...
 
Thanks for your interest in this subject.

I have ID CS.

For instance, first word on the left side is computer, followed by an explanation, and the last on the right side is cummulate, with its explanation.

What I need is to automatically place the "computer" on the upper left header, and "cummulate" on the upper right header. And if I change spacing or anything, I need ID to automatically change the first and the last word explained... You know how a normal dictionary looks like.

Thanks in advance,
Vladan Galebovic
 
I'm also looking for such a process (I'm presuming it has to be scripted in AppleScript or JavaScript) for a member-directory that's going out the door. Anyone who can point me at even a _skeletal_ script for this sort of thing would make our Production Manager's day!
 
Follow-up information:

The basic format of the aforementioned directory is:

<Style: "Name">last-name, first-name
<Style: "Body">member-address-and-other-data

At the top of every page, we're looking for an entry along the lines of "Last-name(1) - Last-name(x)" where each is the first and last "Name" style-paragraph-entry on the page, respectively.

I had a go at a quick AppleScript to go through the entire document, one paragraph at a time, and add what should've been the first and last paragraphs, but it ended up grabbing things arbitrarily (because the object-id's are arbitrary, perhaps? I haven't been able to dig into it enough to figure it out yet).

Production-systems are InDesign CS, Mac OS X (10.2, I believe)
 
Hi,

I do not know almost anything about programming, so I am looking for an off-the-shelf solution.

But, here is a suggestion: what about the nested style which starts at the beginning of the paragraph, and ends before the "-" sign, which is usual sign to separate a term from its explanation.

Thanks,
Vladan Galebovic
 
Well, I did manage to get a working (if slow - it's taken an hour to get the first nine pages of all 184 ::sigh:: ) AppleScript put together. Here it is:

Code:
tell application "Finder"
	set outFile to open for access file "Mac HDD:directory_running_heads.txt" with write permission
	set tmpFile to file "Mac HDD:directory_running_heads.txt"
end tell
tell application "InDesign CS"
	set theDoc to the active document
	set thePages to every page of theDoc
	set headText to ""
	set theHeaderID to the id of paragraph style "NAME COPY" of theDoc
	set thePageNo to 0
	repeat with thePage in thePages
		set thePageNo to thePageNo + 1
		if thePageNo / 2 is thePageNo mod 2 then
			set styleTag to "<running-head-left>"
		else
			set styleTag to "<running-head-right>"
		end if
		set theParagraphs to the object reference of every paragraph of every text frame of thePage
		set tmpStartItem to "ZZZZZZZZ"
		set tmpEndItem to "AAAAAAAA"
		repeat with theParagraph in theParagraphs
			if the id of the applied paragraph style of theParagraph is theHeaderID then
				if theParagraph < tmpStartItem then
					set tmpStartItem to theParagraph
					log "New Start Item: " & tmpStartItem
				end if
				if theParagraph > tmpEndItem then
					set tmpEndItem to theParagraph
					log "New End Item: " & tmpEndItem
				end if
			end if
		end repeat
		set tmpLength to the number of characters of tmpStartItem
		set dissectMe to characters 1 thru tmpLength of tmpStartItem
		log dissectMe
		set tmpStartItem to ""
		set tmpBreak to false
		set charNo to 0
		repeat until tmpBreak is true
			set charNo to charNo + 1
			if item charNo of dissectMe is "," then
				set tmpBreak to true
			else
				set tmpStartItem to tmpStartItem & item charNo of dissectMe
			end if
		end repeat
		set tmpLength to the number of characters of tmpEndItem
		set dissectMe to characters 1 thru tmpLength of tmpEndItem
		set tmpEndItem to ""
		set tmpBreak to false
		set charNo to 0
		repeat until tmpBreak is true
			set charNo to charNo + 1
			if item charNo of dissectMe is "," then
				set tmpBreak to true
			else
				set tmpEndItem to tmpEndItem & item charNo of dissectMe
			end if
		end repeat
		set headText to styleTag & tmpStartItem & " - " & tmpEndItem & "
"
		log "Current item: " & styleTag & tmpStartItem & " - " & tmpEndItem
		tell application "Finder" to write headText to outFile
	end repeat
end tell
tell application "Finder"
	close access outFile
end tell
tell application "TextEdit"
	open tmpFile
	display dialog "This is a temporary file, and may be saved to another location for your convenience.

Use the \"Save As...\" function, or move it in the Finder..." buttons {"OK"} default button "OK"
end tell

If this'd be of any use to anyone else, feel free to have at it. Just copy the script, paste it into a new Script Editor file, and run it. Caveats: As posted, it requires that the document that the running heads are being built with is open and active in InDesign, that the items to be collated intot he running heads are in a paragraph style named "NAME COPY" (not sure if it's case-sensitive), and it breaks the running-head items down to the every character before the first comma in the item (i.e., "Smith, John J" would be rendered down to "Smith", or "Doe Jr, John" would result in "Doe Jr"). It'll generate a "directory_running_heads.txt" file at the root of the hard-drive, with "<running-head-left>" and "<running-head-right>" at the beginning of each paragraph that can be placed into an InDesign file and formatted with the global search-and-replace (from the Story Editor).

It's slow, but it runs (at least so far... it ran the first couple of pages in under five minutes, and has slowed down now to about 10-15 minutes per page as things stand right now...). It's probably not an ideal solution, either - just a quick hack I threw together - and it's certainly not elegant, but it works, at least for my purposes, for now. It might be modifiable for yours as well...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top