🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #20800

Re: Insert soft return (newby)

#20800
From: Jay Fraser
Date: Tue, 28 May 2002 21:05
21 lines
4209 bytes
Olav -- 

Thanks again for your last msg. I didn't study it this weekend (surprize!) but have been dinking with it today. Right now I have the test text flowed into a story in ID2.  It already has char. formatting, so I removed set myString, set myCharStyle, myFormatText and myGetBounds. 

I want to play w/ myFormatText a little later; I don't quite understand it yet. But first some quex: 

1) if the script does not find anything w/ appropriate character style, I get an error "...myFoundItems is not defined". I tried to add some error checking, but it doesn't work. 

2) what is the "^y" character you search for in the "widowed phone number" section? 

This is what the script looks like now: 

 

--Format telephone listings.  tell application "InDesign 2.0.1" 	if (count documents) > 0 then 		--Clear InDesign's find/change preferences  		set find preferences to nothing 		set change preferences to nothing 		set myDocument to active document 		tell myDocument 			set myPage to page 1 			tell myPage 				--Okay, now we want to find addresses that span multiple lines.  				set myFoundItems to {} 				set myFoundItems to search myDocument with find attributes {applied character style:character style "Address" of myDocument} 				if myFoundItems = {} then 					set myErrorMessage to "No qualifying Character Style was found." 					error 				else 					repeat with myCounter from (count myFoundItems) to 1 by -1 						set myFoundItem to item myCounter of myFoundItems 						set myFirstBaseline to baseline of character 1 of myFoundItem 						set myLastBaseline to baseline of character -1 of myFoundItem 						set myParaEndBaseline to baseline of character -2 of paragraph 1 of myFoundItem 						--Next, test the found items. Compare the first baseline of the found item to the last  						--baseline of the found item, and also compare the baseline of the first found item to the  						--baseline of the last character in the paragraph. If the baseline values are not equal, add  						--a line break before the first character of the address.  						if myFirstBaseline is not equal to myLastBaseline � 							or myFirstBaseline is not equal to myParaEndBaseline then 							set contents of insertion point 1 of myFoundItem to forced line break 						end if 					end repeat 				end if 				--Clear InDesign's find/change preferences  				set find preferences to nothing 				set change preferences to nothing 				set myFoundItems to {} 				--Next, search for phone numbers that have ended up on a line by themselves.  				set myFoundItems to search story 1 of myDocument with find attributes {find text:"^y"} 				if (count myFoundItems) = 0 then 					set myErrorMessage to "No ^y Character was found." 					error 				else 					repeat with myCounter from (count myFoundItems) to 1 by -1 						set myFoundItem to item myCounter of myFoundItems 						set myFirstBaseline to baseline of character 1 of myFoundItem 						set myLastBaseline to baseline of character -1 of myFoundItem 						if myFirstBaseline is not equal to myLastBaseline then 							set contents of insertion point 1 of myFoundItem to forced line break 						end if 					end repeat 				end if 				--Clear InDesign's find/change preferences  				set find preferences to nothing 				set change preferences to nothing 			end tell 		end tell 	else 		activate 		display dialog "Please open a document and try again." 	end if end tell 

 

Thanks again for writing this. I'm learning! 

Jay
Technical Details
Message-ID: <ef8b754.7@WebX.aaQKaf7vad4>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!peer.news.opaltelecom.net!iad-peer.news.verio.net!news.verio.net!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <ef8b754.-1@WebX.aaQKaf7vad4>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f939a,4c5b67e22acd13de
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2002-05-28 14:08:02 PST
From: "Jay Fraser" <jayfraser@yahoo.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!peer.news.opaltelecom.net!iad-peer.news.verio.net!news.verio.net!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: Insert soft return (newby)
Message-ID: <ef8b754.7@WebX.aaQKaf7vad4>
Date: Tue, 28 May 2002 14:05:24 -0700
References: <ef8b754.-1@WebX.aaQKaf7vad4>
Lines: 98
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit