🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #197

Re: Using for ... in with arrays

#197
From: Fred_Goldman
Date: Wed, 01 Apr 2009 00:03
17 lines
1417 bytes
It seems that myDoc.characterStyles is a regular object with a length 
property added to it, not an actual array.

Another major difference between the for/in and traditional loops is 
that the for/in loop will not loop through the full length of the array 
if it has undefined items whereas the traditional for loop will.

For example:

myDoc = app.activeDocument;
myArray = new Array(myDoc.characterStyles.length)
myArray[3] = 4;
for (j in myArray)
$.writeln(j)

Will only loop once despite the fact that there may be more than one 
character style in the document.
Technical Details
Message-ID: <8EBB15F4B39BF4EE3FCE426C328C5867@in.webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!news2.glorb.com!news.glorb.com!newshub.sdsu.edu!webcrossing
References: <59b87616.-1@webcrossing.la2eafNXanI> <59b87616.2@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: Fred_Goldman@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!news2.glorb.com!news.glorb.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: Using for ... in with arrays
Message-ID: <8EBB15F4B39BF4EE3FCE426C328C5867@in.webcrossing.la2eafNXanI>
Date: Tue, 31 Mar 2009 17:03:30 -0700
References: <59b87616.-1@webcrossing.la2eafNXanI> <59b87616.2@webcrossing.la2eafNXanI>
Lines: 18
User-Agent: Thunderbird 2.0.0.21 (Windows/20090302)
X-Antivirus: avast! (VPS 090330-0, 03/30/2009), Outbound message
X-Antivirus-Status: Clean
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit