🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.photoshop.scripting
Article #511

Re: determine if file has never been saved in javascript

#511
From: xbytor
Date: Sat, 03 Jan 2009 20:55
26 lines
1352 bytes
The try/catch technique is the simplest. The other way looks like this:
(extracted from xtools/xlib/stdlib.js)

-X

function isDocumentNew(doc){
   // assumes doc is the activeDocument

   cTID = function(s) { return app.charIDToTypeID(s); }


   var ref = new ActionReference();
   ref.putEnumerated( cTID("Dcmn"),
                        cTID("Ordn"),
                        cTID("Trgt") );  //activeDoc
   var desc = executeActionGet(ref);

   var rc = true;
   if (desc.hasKey(cTID("FilR"))) {  //FileReference
     var path = desc.getPath(cTID("FilR"));
     if (path) {
       rc = (path.absoluteURI.length == 0);
     }
   }
   return rc;
};
Technical Details
Message-ID: <71A54E52D79BAE0315929BFDEF420B2B@in.webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!newshub.sdsu.edu!webcrossing
References: <59b76a8b.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f5839,c148bdfc9cff5bad
X-Google-Attributes: gidf5839,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: xbytor@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.photoshop.scripting
Subject: Re: determine if file has never been saved in javascript
Message-ID: <71A54E52D79BAE0315929BFDEF420B2B@in.webcrossing.la2eafNXanI>
Date: Sat, 3 Jan 2009 12:55:02 -0800
References: <59b76a8b.-1@webcrossing.la2eafNXanI>
Lines: 26
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