Article View: adobe.scripting.indesign
Article #8798Re: The top 4 things that bug me about InDesign scripting so far
From: Dave_Saunders
Date: Tue, 26 Sep 2006 16:27
Date: Tue, 26 Sep 2006 16:27
20 lines
1876 bytes
1876 bytes
There are big differences between using the collection object instead of an array.
The collection object is more of a pointer into the collection than an array of references to the members of the collection. The collection object is permanently current, so when you access a member of a collection (whether directly or via a variable) you always get the current member that matches your method of addressing it. An array of references would have to be held in a variable and it would be a snapshot of the collection at that point in time.
The collection can be referenced from the tail end using .item(-n) where an array cannot -- you can set up negative indexes into an array, but that's all that they are. myArray[-1] might or might not exist, but it is not the same as myArray[myArray.length - 1].
The collection can be accessed using the collection methods, including the undocumented everyItem(). Arrays cannot.
Some of those methods aren't very useful, it seems to me, but that might just be a matter of taste. But I make frequent use of:
everyItem()
itemByRange()
item(n) where n is a number, positive or negative
item("Name") rather that itemByName("Name") which is functionally equivalent
and I make occasional use of
itemByID()
Dave
Technical Details
Message-ID:
<3bc1c832.3@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!news.isoc.lu!webcrossingReferences:
<3bc1c832.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,9c31209a8bed7967 X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII-7-bit From: Dave_Saunders@adobeforums.com Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!news.isoc.lu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Re: The top 4 things that bug me about InDesign scripting so far Message-ID: <3bc1c832.3@webcrossing.la2eafNXanI> Date: Tue, 26 Sep 2006 09:27:26 -0700 References: <3bc1c832.-1@webcrossing.la2eafNXanI> Lines: 33 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit