--On Tuesday, March 18, 2003 8:51 PM -0800 "Nicholas G. Thornton" <[EMAIL PROTECTED]> wrote:

I'm trying to run an applescript from perl using
MacPerl::DoAppleScript(). The script when compiled works fine as
AppleScript, but I can't seem to get it to work quite right in MacPerl.
And so I put it to you guru's who've tangled with
MacPerl::DoAppleScript() before.

After setting $AppleScript to the script, my code goes something like...

MacPerl::DoAppleScript($AppleScript, $passed_file) or die $@;

... But from this line I get the error...

# Usage: MacPerl::DoAppleScript(script).

Do you understand what this means? MacPerl is telling you that you passed the wrong number of arguments.


...I get the same error if I use <<END_SCRIPT rather than the variable
$AppleScript, and if I get rid of the passed file I get an error (because
the script is a droplet only and so it expects the file.)

Your code must conform to the API, not vice versa.


I'd guess that the other error occurs because your script lacks a run handler -- the presence or absence of an open handler is ignored.

So what am I missing?

You need to modify the script to include the parameter. So instead of:


my $script = <<EOS;
on open itemList
  tweak every item of itemList
end open
EOS

you'd write:

my $script = <<EOS;
tweak FOO
EOS
$script =~ m/FOO/$passed_file/g;

Share and enjoy.

Josh




Reply via email to