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

re: [MacPerl] Send Arg to MacPerl from AS



pudge@pcix.com (Chris Nandor) writes:
} 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,

Do Script wants a string, but Applescript doesn't do string interpolation
the way Perl does.  You have to do it the Applescript way:

property test : 1
tell application "MacPerl"
Do Script "$x = 1 + "&(test as string)&";print\"$x\\n\";MacPerl::Reply($x);"
end tell

(The print's there just so I could make sure the right thing was
happening inside MacPerl.) You can't "return $x" since Applescript
doesn't know what $x is.  Note that you have to use MacPerl::Reply to
get something back (or use batch mode).  The result of the Do Script
will be in the Applescript variable "result" (command-L in the Script
Editor  will show it to you), and note that it's a string.

} 
} 
} #================================================================
} perl -e 'srand();if(rand>.5){$i=0;foreach(@ARGV){@$i=split(//);$z
} [$i]=0;foreach$l(@$i){$s[$i][$z[$i]]=$l;$z[$i]++;}$i++;}foreach$m
} (@s){foreach$g(@{$m}){print$g}print" ";$m++}}else{print(join(" ",
} @ARGV))}print"\n"' McClellan Clan Motto: Think On
} 
} Chris Nandor                                       pudge@pcix.com
} PGP Key 0xB76E72AD                    http://pudge.petersons.com/
} 
} 
} 
---
--------
Paul J. Schinder
NASA Goddard Space Flight Center,
Code 693, Greenbelt, MD 20771 USA
schinder@pjstoaster.pg.md.us