Article View: adobe.scripting.indesign
Article #9446Re: JS: Reading Text out of EPS files
From: Dave_Saunders
Date: Sun, 20 Aug 2006 22:54
Date: Sun, 20 Aug 2006 22:54
51 lines
2315 bytes
2315 bytes
Apparently, I didn't delete enough garbage.
OK, that might be a clue! My message got cut off.
Thanks Shane.
There's something truly weird going on. I wrote this:
var myFile = File.openDialog("Pick an eps file");
if (myFile == null) { exit() }
myFile.open("r");
myText = myFile.read();
myFile.close();
alert(myText);
and all I got was this:
// Well, you get the idea from the two previous messages
So, then I tried your suggestion and put 24 into the read command as a limit on the number of characters. The result was the same.
So it occurred to me to check to see how long myText was. It said 24 -- hello! Maybe the problem isn't reading the data but writing it back out in an alert.
So, I changed it to 48. Same thing (only this time it said the length was 48).
So, I tried slicing the string after reading it:
var myFile = File.openDialog("Pick an eps file");
if (myFile == null) { exit() }
myFile.open("r");
myText = myFile.read();
myFile.close();
alert(myText.slice(8));
and blow me, there was the text.
So, I tried changing the slice value to zero instead of 8 -- this is tantamount to telling slice() to give me back the same string I gave it.
Result: the whole string.
So, as a final test, I took out the slice command, taking me right back to where I started, and now the bloody script works on any EPS file.
I already have a headache, but now it's getting worse. Apparently, my JavaScript engine had gotten itself into a state where it couldn't read these files but now it is out of the state. What did I do to fix it? Don't ask me.
How do I know if my script will work for the client? Don't ask me that either.
Grrrr.
But thanks again.
Dave
Technical Details
Message-ID:
<3bc153be.3@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!news.ecp.fr!news.stben.net!webcrossingReferences:
<3bc153be.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,41b63fc201f6d7d5 X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII-7-bit From: Dave_Saunders@adobeforums.com Newsgroups: adobe.scripting.indesign Subject: Re: JS: Reading Text out of EPS files Message-ID: <3bc153be.3@webcrossing.la2eafNXanI> Date: Sun, 20 Aug 2006 15:54:54 -0700 References: <3bc153be.-1@webcrossing.la2eafNXanI> Lines: 61 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!news.ecp.fr!news.stben.net!webcrossing