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

Re: [MacPerl] Send Arg to MacPerl from AS



>Is there a way to send MacPerl an argument from AppleScript and vice versa,
>i.e.:
>
>property test : 1
>tell application "MacPerl"
>        Do Script "$x = 1 + test"
>end tell
>return $x
>
>Thanks,
>
Almost right. DoScript takes a list which has the script name as the first
item and the arguments to be passed via $ARGV as the next items.

for example:

tell application "MacPerl"
    set howie to Do Script {file "Fat Man:MacPerl Ä:Dumb show","arg0","arg1"}
end tell

This will run the script "Dumb Show" in the "MacPerl Ä" folder of disk "Fat
Man"  - you can set up a variable for this or code it in line as I did -
and the script will execute with ARGV[0] = arg0, etc. The arguments can be
passed as strings.

As for the return via the AppleScript variable howie, this comes from
MacPerl and should be coded there using &MacPerl'Reply("whatever text you
like");
My version of "Dumb Show" was simply
    #! perl
    require "GUSI.ph";
    &MacPerl'Reply("This is what you said: $ARGV[0] and $ARGV[1].");

It's also possible to have a dialog between your AS and MacPerl. For more
details on this (wimp that I am, I haven't tried it), see the
"MacPerl.Frontend" document in your package.

Happy Mac'ing!

Peter Tattersall
Perk Consulting
ptatters@astral.magic.ca
http://www.magic.ca/~ptatters/rolling.html