[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Calling a program frame MacPerl



On Fri, 26 Jan 1996 13:58:44 -0800 (PST), trr@frame.com (Tim Ringwood) wrote:
 > I need to call "X.EXE" from a MacPerl where X.EXE is unknown.

(DOSisms, yech.)

 > I know I call an AppleScript and to a tell and X.EXE will run, but
 > I have to hardcode the path and program name in. As I said the
 > program name is unknown so this requires the user alter the Perl
 > script by hand, not my first choice.
<...>
 > My first thought is to have MacPerl create a samll MacPerl script
 > which calls an Applescript. However I can't figure out how call
 > MacPerl from MacPerl (I can do it on UNIX and DOS, but I've been
 > using the Mac for less than a month). Is this possible?

This sounds like a classic case for eval().
  Something along these lines:

    :
    :
$program = "Macintosh HeaD:usr:bin:Some script huh" unless $program;

$script = <<"HEDE";
    :
    -- Your actual script goes here
    :
HEDE

eval qq! &macperl'doAppleScript("tell $program $script"); !;

    :
    :

The 'qq' trick means use ! as a double quote. So qq!Word! is
syntactically equivalent to "Word" (and q!Word! is 'Word'). 
This is just so you can use single and double quotes in the strings
without too much backslashing.
  I put the script in a variable just to make it more readable; you
can certainly put it inside the eval clause if you like.

/* era */

I'm not versed in AppleScript, and I'm not writing this at my Mac.
Caveat emptor. 

-- 
See <http://www.ling.helsinki.fi/~reriksso/> for mantra, disclaimer, etc.