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

Re: [MacPerl] MacPerl->Applescript



>Is there any way in MacPerl to pass more than just one string to
>AppleScript?? I would like to pass back about 4-5 strings to AppleScript
>and have them take seperate variables in AppleScript for passage back to
>Tango in the form of a list of lists
>{{"blah","subblah"},{"moreblah","somefoo","fooey"}}

It is sometimes useful to pass references to AppleScript:

        #!perl
        $str = [["a", "b", "c"], ["d", "e", "f"]];

        $out = MacPerl::DoAppleScript qq(
           set myList to "$str->[0][0]" as list
           set myList to myList & "$str->[1][0]"
           myList
        );

        print $out;  # returns {"a", "d"}

To get an AppleScript nested list output is more awkward but it can be done
like this for instance:

        $out = MacPerl::DoAppleScript qq(
           set myOne to "$str->[0][0]" as list
           set myOne to myOne & "$str->[0][1]"
           set myTwo to "$str->[1][0]" as list
           set myTwo to myTwo & "$str->[1][1]"
           set myList to {"x", "y"}
           set item 1 of myList to myOne
           set item 2 of myList to myTwo
           myList
        );
        print $out; # yields {{"a","b"},{"d","e"}}

Alan Fry



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch