Article View: adobe.scripting.indesign
Article #464Re: CS3 JS flag which page has empty frame
From: Dirk_Becker
Date: Sat, 21 Mar 2009 14:45
Date: Sat, 21 Mar 2009 14:45
39 lines
1575 bytes
1575 bytes
The following script is a small modification of Dave's previously posted.
It illustrates two advanced javascript concepts:
* The nested function can refer to outside local variables of its closure.
* Code enclosed by a try-finally will execute the finally clause even if there is a return in between.
function setupMeasures(doc)
{
var vp = doc.viewPreferences.properties;
var zp = doc.zeroPoint;
doc.viewPreferences.properties = {
horizontalMeasurementUnits: MeasurementUnits.points,
verticalMeasurementUnits: MeasurementUnits.points,
rulerOrigin: RulerOrigin.spreadOrigin,
}
doc.zeroPoint = [0,0];
return function ()
{
doc.viewPreferences.properties = vp;
doc.zeroPoint = zp;
alert("Here!");
}
}
(function main()
{
var restoreMeasures = setupMeasures(app.activeDocument);
try {
// do your stuff
return 42;
} finally {
restoreMeasures();
}
})();
Dirk
Technical Details
Message-ID:
<59b83b3d.8@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossingReferences:
<59b83b3d.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,5f85c25f887dafb2 X-Google-Attributes: gidf939a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Dirk_Becker@adobeforums.com Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Re: CS3 JS flag which page has empty frame Message-ID: <59b83b3d.8@webcrossing.la2eafNXanI> Date: Sat, 21 Mar 2009 07:45:46 -0700 References: <59b83b3d.-1@webcrossing.la2eafNXanI> Lines: 46 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit