🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #18659

Re: Newbie contemplating something far too complex?

#18659
From: Dave Saunders
Date: Fri, 28 Feb 2003 21:44
51 lines
2573 bytes
Diane,

I think this script does the job. I don't know how fast it will be for a 500 long list, though.

-- gather sentences for sorting
tell application "InDesign 2.0.2"
 set myStory to parent story of selection
 set myList to {}
 repeat with n from 1 to count of paragraphs of myStory
  copy {n, paragraph n of myStory} to end of myList
 end repeat
end tell

-- delete noise words
set noiseWords to {"A ", "The "}
repeat with theWord in noiseWords
 repeat with n from 1 to count of myList
  set theLen to length of theWord
  if (characters 1 through theLen of item 2 of item n of myList) as string = contents of theWord then
   set item 2 of item n of myList to (characters (theLen + 1) through -1 of item 2 of item n of myList) as string
  end if
 end repeat
end repeat

-- sort list
repeat with n from 2 to count of myList
 if contents of item 2 of item n of myList < contents of item 2 of item (n - 1) of myList then
  repeat with m from n - 1 to 1 by -1
   if contents of item 2 of item (m + 1) of myList < contents of item 2 of item m of myList then
    copy item (m + 1) of myList to temp
    copy item m of myList to item (m + 1) of myList
    copy temp to item (m) of myList
   end if
  end repeat
 end if
end repeat

-- update story to reflect sort
tell application "InDesign 2.0.2"
 if character -1 of myStory is not return then set contents of insertion point -1 of myStory to return
 set theLim to count of paragraphs of myStory
 repeat with n from 1 to theLim
  set contents of insertion point 1 of paragraph (item 1 of item n of myList) of myStory to return
  move paragraph ((item 1 of item n of myList) + 1) of myStory to after paragraph (-1) of myStory
 end repeat
 repeat with n from 1 to theLim
  delete paragraph 1 of myStory
 end repeat
end tell

Dave
Technical Details
Message-ID: <1de80f24.15@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeeds.sol.net!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <1de80f24.-1@WebX.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,45607331d5b88ff9
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-02-28 14:07:48 PST
From: "Dave Saunders" <daves@pdsassoc.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeeds.sol.net!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: Newbie contemplating something far too complex?
Message-ID: <1de80f24.15@WebX.la2eafNXanI>
Date: Fri, 28 Feb 2003 13:44:35 -0800
References: <1de80f24.-1@WebX.la2eafNXanI>
Lines: 59
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit