🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #17964

Re: Question about repeat [AS]

#17964
From: Shane Stanley
Date: Thu, 01 May 2003 07:07
24 lines
1642 bytes
Your problem is that you're using object references to paragraphs. These are
in the form of text ranges like "text from character 945 to character 966 of
story...", and every time you replace a paragraph, unless you replace it
with exactly the same number of characters, all following object references
to paragraphs in that story are out of date.

The solution is easy, and probably a bit quicker:

tell application "InDesign 2.0.2"
 tell document 1
  repeat with i from 1 to count of stories
   tell story i
    repeat with j from 1 to count of paragraphs
     set this_text to contents of paragraph j
     set the new_text to my translate("en_fr", this_text)
     set contents of paragraph j to new_text & return
    end repeat
   end tell
  end repeat
 end tell
end tell

-- 
Shane Stanley,  sstanley@myriad-com.com.au
Technical Details
Message-ID: <BAD704E3.58632%sstanley@myriad-com.com.au>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <1de8f324.-1@WebX.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,f58fa0f66d7887b5,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-05-01 00:07:47 PST
From: Shane Stanley <sstanley@myriad-com.com.au>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: Question about repeat [AS]
Message-ID: <BAD704E3.58632%sstanley@myriad-com.com.au>
Date: Thu, 1 May 2003 00:07:48 -0700
References: <1de8f324.-1@WebX.la2eafNXanI>
Lines: 29
User-Agent: Microsoft-Outlook-Express-Macintosh-Edition/5.0.6
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit