List which contains more than 10,000 items - Help

Hi There,

Need some help regarding list. Objective of my script is to find the smallest point size applied to the text inside an InDesign document. InDesign document contains quite a bit of text involved. I have problem, getting them as a list and do a sort. My script always freezes. Tried displaying as a dialog, tried writing to a file… no luck at all.

Your assistance will be much appreciated.

Note: I have used StefanK’s script to sort the point size. (Thanks to StefanK)

Here is my script:

tell application "Adobe InDesign CS3"
	set curDoc to active document
	set my_list to point size of every character of every story of curDoc
end tell
ascendingsort(my_list)
my_list
display alert "Smallest font size found in the artwork: " & item 1 of my_list & "pts"
set theFilePath to (path to desktop as string) & "test.txt" as string
--set theFileReference to open for access theFilePath with write permission -- Tried to write this to a file, no luck.
--set eof of theFileReference to 0
--write my_list to theFileReference starting at eof as text
--close access theFileReference

on ascendingsort(theList)
	script o
		property lst : theList
	end script
	
	repeat with i from (count theList) to 2 by -1
		set A to beginning of o's lst
		repeat with j from 2 to i
			set B to item j of o's lst
			if (A > B) then
				set item (j - 1) of o's lst to B
				set item j of o's lst to A
			else
				set A to B
			end if
		end repeat
	end repeat
end ascendingsort

Your script will run much quicker, and your list will be much smaller, if you get the font size of every text style range, rather than every character.

Shane,

You are a ROCK STAR. :smiley:

Its super fast when i use “text style range”. Thanks a Million.

Rgds
JaiM