Article View: adobe.scripting.indesign
Article #10241Re: [JS CS2] Open a text file and parse line by line
From: chad_edge
Date: Wed, 28 Jun 2006 20:17
Date: Wed, 28 Jun 2006 20:17
24 lines
1692 bytes
1692 bytes
Update:
I've fixed the opening of the file. Now I need to parse the file line-by-line looking for the strings and variables I need to create (eg: "dimensions { 168000 225000 } " and "string { columns "6.0" } ").
Here's what I've got:
var openPilFile = File(pilFile);
var pilFileCreated = openPilFile.created;
var pilFileLength = openPilFile.length;
var pilFileEncoding = openPilFile.encoding;
var pilFileExists = openPilFile.exists;
var pilFileLineFeeds = openPilFile.lineFeed;
var pilFileContents = openPilFile.open("r");
var openPilFileContents = openPilFile.read();
var alertText = "Your .pil file has been opened.";
alertText = alertText+"\n Length: "+pilFileLength;
alertText = alertText+"\n Created: "+pilFileCreated;
alertText = alertText+"\n Encoding: "+pilFileEncoding;
alertText = alertText+"\n Exists: "+pilFileExists;
alertText = alertText+"\n LineFeeds: "+pilFileLineFeeds;
alertText = alertText+"\n Open: "+pilFileContents;
alertText = alertText+"\n Contents: "+openPilFileContents;
alert(alertText);
Technical Details
Message-ID:
<3bc0c041.1@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news2.volia.net!news.musoftware.de!news.albasani.net!news.ecp.fr!news.stben.net!webcrossingReferences:
<3bc0c041.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,3bc9981b28d99c9 X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII-7-bit From: chad_edge@adobeforums.com Newsgroups: adobe.scripting.indesign Subject: Re: [JS CS2] Open a text file and parse line by line Message-ID: <3bc0c041.1@webcrossing.la2eafNXanI> Date: Wed, 28 Jun 2006 13:17:23 -0700 References: <3bc0c041.-1@webcrossing.la2eafNXanI> Lines: 26 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news2.volia.net!news.musoftware.de!news.albasani.net!news.ecp.fr!news.stben.net!webcrossing