Article View: adobe.scripting.indesign
Article #201Re: Using for ... in with arrays
From: Olav_Kvern
Date: Tue, 31 Mar 2009 17:50
Date: Tue, 31 Mar 2009 17:50
11 lines
1923 bytes
1923 bytes
xbytor wrote: "There are 'Collection' objects in Adobe/JS-land that look kinda like Arrays but really aren't. It would have been very nice if they would have made these collection objects proper subclasses of Array." That won't work for all of the languages we support. In VBScript, for example, these collections give us capabilities that we would not otherwise have (ItemByName, ItemByRange, etc.). While we could extend Array in JavaScript, we can't do that in the other languages (or, at least, we can't do so given our current process). There are a lot of things that our collections support that arrays don't (except in AppleScript, where arrays and collections work about the same way--in fact, our collections are based on the AppleScript model). Our "one size fits all" approach does sometimes mean that we can't take advantage of all of the features of a specific language, but it's better than the alternatives--hand coding for each language you want to support (look at some of the other CS applications, which have different DOMs for differing languages), or limiting scripting to a single language. This is also why I always use the collection.item(index) form when working with these collections and the array[index] form for arrays. This reminder makes it much easier for me when I'm updating scripts. Thanks, Ole
Technical Details
Message-ID:
<59b87616.10@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!newshub.sdsu.edu!webcrossingReferences:
<59b87616.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,709551d954315a95 X-Google-Attributes: gidf939a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Olav_Kvern@adobeforums.com Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Re: Using for ... in with arrays Message-ID: <59b87616.10@webcrossing.la2eafNXanI> Date: Tue, 31 Mar 2009 10:50:03 -0700 References: <59b87616.-1@webcrossing.la2eafNXanI> Lines: 27 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit