🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #20419

Re: Dave Saunders' Running Heads Script

#20419
From: Dave Saunders
Date: Tue, 30 Jul 2002 11:11
50 lines
2046 bytes
Of course, there's the dreaded paragraph that consists of just a space to be considered (or the one that has five tabs and nothing else). 

... length greater than 6  

would deal with these and still probably not miss anything important. 

Or, maybe one should use a try loop: 

tell application "InDesign 2.0.1" 
	set myFrame to item 1 of selection 
	set Filter to -1 
	repeat 
		try 
			tell myFrame 
				set theWord to word 1 of paragraph Filter 
			end tell 
			exit repeat 
		on error 
			set Filter to Filter - 1 
		end try 
	end repeat 
	return theWord 
end tell 
 

At first, I wrote the more complicated (but theoretically quicker except for those cases of pseudo blank paragraphs): 

tell application "InDesign 2.0.1" 
	set myFrame to item 1 of selection 
	set Filter to 1 
	repeat 
		try 
			tell myFrame 
				set theWord to word 1 of paragraph-1 whose length > Filter 
			end tell 
			exit repeat 
		on error 
			set Filter to Filter + 1 
			if Filter > 10 then 
				beep 
				exit repeat 
			end if 
		end try 
	end repeat 
	return theWord 
end tell 

But this just errored out when Filter hit 11, so there's something wrong with the statement that gets the word, but I always have trouble with "Whose" statements and generally avoid them like the plague. 

Dave
Technical Details
Message-ID: <ef9de98.20@WebX.aaQKaf7vad4>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-01!sn-xit-04!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <ef9de98.-1@WebX.aaQKaf7vad4>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,37e35bfe49790ac7
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2002-07-30 04:41:13 PST
From: "Dave Saunders" <daves@pdsassoc.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-01!sn-xit-04!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: Dave Saunders' Running Heads Script
Message-ID: <ef9de98.20@WebX.aaQKaf7vad4>
Date: Tue, 30 Jul 2002 04:11:58 -0700
References: <ef9de98.-1@WebX.aaQKaf7vad4>
Lines: 54
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit