Article View: adobe.scripting.indesign
Article #10270Re: Getting an Array of All Items that Have One Label
From: Dirk_Becker
Date: Thu, 29 Jun 2006 10:28
Date: Thu, 29 Jun 2006 10:28
14 lines
1374 bytes
1374 bytes
Various specifier forms from AppleScript are available as methods in JavaScript, with the only exception of "whose". They have the (speed) advantage of being evaluated within the application rather than within the scripting engine.
You can simulate the behaviour in JavaScript with the following snippet:
// the following line makes the PageItems object available
app.activeDocument.pageItems;
PageItems.prototype.itemWhose = function (f)
{
var result = [];
for( var i=0; i<this.length; i++ ) if( f.apply(this.item(i)) ) result.push(this.item(i)); return result; }
// use it like here:
a1 = app.activeDocument.pageItems;
a2 = a1.itemWhose( function() { return this.label=="my label" } );
Technical Details
Message-ID:
<3bc0bf0b.2@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!news2.volia.net!news.musoftware.de!news.albasani.net!news.ecp.fr!news.stben.net!webcrossingReferences:
<3bc0bf0b.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,277b8feb57507843 X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII-7-bit From: Dirk_Becker@adobeforums.com Newsgroups: adobe.scripting.indesign Subject: Re: Getting an Array of All Items that Have One Label Message-ID: <3bc0bf0b.2@webcrossing.la2eafNXanI> Date: Thu, 29 Jun 2006 03:28:30 -0700 References: <3bc0bf0b.-1@webcrossing.la2eafNXanI> Lines: 23 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!news2.volia.net!news.musoftware.de!news.albasani.net!news.ecp.fr!news.stben.net!webcrossing