🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #2259

Re: [JS] CS3 file.openDialog ()

#2259
From: Bob Stucky
Date: Fri, 19 Dec 2008 19:08
22 lines
1600 bytes
Write the file object to a file, something like this:

var prefsFile = new File( Folder.userData.absoluteURI + "/myScript/baseFile.jsx" );
// create the parent folder just to be sure
prefsFile.parent.create();

if ( prefsFile.open( "r" ) ) { // then the file exists and is openable
  var file = eval( prefsFile.read() );
  prefsFile.close();
  var file = file.openDlg( "Pick a file, Bozo" );
} else {
  var file = File.openDialog( "Pick a file, Bozo" );
}
if ( file ) {
  prefsFile.open( "w" );
  prefsFile.write( file.toSource() );
  prefsFile.close();
}

I do this all the time (and I mean ALL the time). I actually use a standard preferences object that stores name-value pairs for persistent data. That object is passed a file on instantiation and can load and save itself and any number of name-value pairs that I want saved. It even stores and recreates objects that are stored as values.

Bob
Technical Details
Message-ID: <59b75018.4@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!news2!feeder.erje.net!newsfeed.straub-nv.de!news.buerger.net!news4us.nl!webcrossing
References: <EC6A0C909B0E62E316337EC10946A1BB@in.webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,4092301e56a7cb3f
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Bob Stucky" <rstucky@starband.net>
Newsgroups: adobe.scripting.indesign
Subject: Re: [JS] CS3 file.openDialog ()
Message-ID: <59b75018.4@webcrossing.la2eafNXanI>
Date: Fri, 19 Dec 2008 11:08:37 -0800
References: <EC6A0C909B0E62E316337EC10946A1BB@in.webcrossing.la2eafNXanI>
Lines: 27
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!news2!feeder.erje.net!newsfeed.straub-nv.de!news.buerger.net!news4us.nl!webcrossing