MACSCRPT Archives

January 2010

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Chris Harbinson <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Fri, 8 Jan 2010 22:22:43 +0000
Content-Type:
text/plain
Parts/Attachments:
text/plain (47 lines)
Ed Stockley wrote:-

 >You may be better off sticking with AppleScript for inDesign.
and Mark J. Reed wrote:-
 >You've got a pretty steep learning curve ahead. Good luck!
Heeding the rather discouraging advice of both of you, I've  
resurrected my old URL Access AppleScript and embedded it in my  
JavaScript. I didn't think of doing that earlier, probably because I  
have been so focussed on learning JavaScript.
My request for help with downloading a URL using JavaScript was met  
with stony silence on Adobe's usually wonderfully helpful InDesign  
Scripting Forum. I thought that this was maybe because it was not a  
specific InDesign issue, more what I expected to be a basic  
JavaScripting technique. So I came here.
Once I saw you responses, I recalled the method given to me by the  
chap who lured me into JavaScripting, Kasyan Servetsky, on the  
Indesign forum, who seems to be a man of some foresight. In one of his  
first replies to me he included an example of compiling and running an  
AppleScript within JavaScript. Thus:-
var myScript =	'set eurosFile to alias \"Macintosh  
HD:Users:chrisharbinson:Documents:EuroRate.odt\"\r';
myScript += 'set the_URL to \"http://www.ecb.int/rss/fxref-gbp.html 
\"\r';
myScript += 'with timeout of 300 seconds\r';
myScript += 'tell application \"URL Access Scripting\"\r';
myScript += 'download the_URL to eurosFile replacing yes\r';  ...
etc. to  the end of the Applescript. Then...
var currentEuroRate = app.doScript(myScript,  
ScriptLanguage.APPLESCRIPT_LANGUAGE);
I've been clambering up Mark's "steep learning curve" since November  
and have spent some painful head-banging sessions in which I have  
spent hours achieving zip... except learning how not to do things.  
It's addictive and I've got the rings under my eyes to prove it.
Given a string to play with, the slicing and dicing power of  
JavaScript is exhilarating and I tend to use its built-in regular  
expressions in preference to messing with InDesign's grep change,  
great though that is.
The following line delivers every text frame in an InDesign document  
in an array.
var myFrame = app.activeDocument.textFrames.everyItem().getElements();
What's not to like about that? And the conversion takes place at  
"blink-and-you'll-miss-it" speed.
Then just when I'm feeling like I've cracked it, I run into a  
roadblock like the problem that's brought me to this forum again. But  
that's scripting.
It's good to have you folks to turn to...

ATOM RSS1 RSS2