🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #8627

Re: Get (relative) index of a paragraph inside a selection of paragraphs

#8627
From: Martin Fischer*
Date: Sun, 01 Oct 2006 18:46
29 lines
2194 bytes
Hi Dave,

I have got problems with 

      mytext = app.selection[0].characters.itemByRange(app.selection[0].index,myIP.index).texts[0];




But 

      mytext = app.selection[0].parentStory.characters.itemByRange(myFirstPoint,myLastPoint).texts[0];




works very well, for myFirstPoint and myLastPoint are indices relative to the parent story, but the selection.

It's tricky to get the counter of the paragraph of a search result inside some selected paragraphs thru the count of paragraphs of a text range.

Robert, I know how to adress the paragraphs of a selection (and to read out their contents). What I didn't know was, how to find out, what is the counter (or range) of a paragraph where the last occurrence of a searched string (within a selection) has been found relatively to the first paragraph:
1. there is a selection of paragraphs;
2. there is a search inside this selection for a string and the length of results is more than 0;
3. my question: in which paragraph, counted from the beginning of the selection, is the last occurrence of the searched string in.

Dave says: make a text range with characters from the index of the first insertion point of the selection and the index of an insertion point (maybe the last) of the last item of the search result and count the paragraphs of this text range. And this is the answer to my question.

Thanks
Martin
Technical Details
Message-ID: <3bc1d60c.6@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeed.freenet.de!news.buerger.net!open-news-network.org!news.isoc.lu!webcrossing
References: <3bc1d60c.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,11f901afe18132ac
X-Google-Attributes: gidf939a,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Martin Fischer*" <martin.fischer@online.de>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeed.freenet.de!news.buerger.net!open-news-network.org!news.isoc.lu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: Get (relative) index of a paragraph
 inside a selection of paragraphs
Message-ID: <3bc1d60c.6@webcrossing.la2eafNXanI>
Date: Sun, 1 Oct 2006 11:46:12 -0700
References: <3bc1d60c.-1@webcrossing.la2eafNXanI>
Lines: 35
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit