🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #1892

Re: pls explain abt prototype

#1892
From: xbytor
Date: Wed, 21 Jan 2009 17:29
43 lines
2675 bytes
Time for my two cents...

As it stands right now, I have three methods added to Array (contains, indexOf, 
lastIndexOf) so that it has an interface that matches String more closely.

On String, I've added 8 or so methods (like contains, trim, and startsWith) for 
stuff that I typically need to do with Strings.

For C-printf-style formatting, I've added String:sprintf, Date:strftime, and 
File:strf.

On Folder, I've added my own implementation of getFiles (the original 
implementation had bugs and didn't support RegExp matching) and some similar 
methods (for doing recursive getFiles calls, for instance).


I have stayed away from extending PS/JS-DOM or ID/JS-DOM classes because not all 
classes have bindings to the interpreter at startup.

While Dirks technique
    app.activeDocument.pages;
    Pages.prototype.fancy = function ()
    {
        $.writeln(this.length);
    }

works fine if there is a open document, it doesn't work in the general case, so 
I can't write a set of extensions, drop them in a startup script and have them 
available for all of my scripts.
I've made specific requests in the past to add some support to the ESTK api for 
binding classes on demand (e.g. $.loadClass('Pages')) so that I could extend DOM 
classes more easily, but it has either fallen on deaf ears or is technically 
infeasible.
What makes this even more 'tragic' is that there is an API for adding JS 
extensions written in C. I would love to be able to selectively implement 
extensions to DOM classes in C to help get the most performance possible out of 
my scripts. Lack of a $.loadClass function makes doing this seamlessly somewhat 
impractical.

In a previous life, I used to embed interpreters (mostly TCL) into existing 
in-house applications, so my opinions might be slightly colored :)

-X
Technical Details
Message-ID: <F9CE203794B55F6F1719AEA08D1CABDC@in.webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newshub.sdsu.edu!webcrossing
References: <59b78cbc.-1@webcrossing.la2eafNXanI> <59b78cbc.0@webcrossing.la2eafNXanI> <859B1F6D0F3E1FCF27AD0D04CAE16809@in.webcrossing.la2eafNXanI> <DDF269DF388271AD269C94A88990C450@in.webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,ba3fc2ccca9a708d
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: xbytor@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: pls explain abt prototype
Message-ID: <F9CE203794B55F6F1719AEA08D1CABDC@in.webcrossing.la2eafNXanI>
Date: Wed, 21 Jan 2009 09:29:12 -0800
References: <59b78cbc.-1@webcrossing.la2eafNXanI> <59b78cbc.0@webcrossing.la2eafNXanI> <859B1F6D0F3E1FCF27AD0D04CAE16809@in.webcrossing.la2eafNXanI> <DDF269DF388271AD269C94A88990C450@in.webcrossing.la2eafNXanI>
Lines: 59
User-Agent: Thunderbird 2.0.0.19 (Macintosh/20081209)
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit