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

Re: [MacPerl] question abou



"Whitney Cunha" <whitney_cunha@sequana.com> writes
>How about just using Applescript rather than buildling the apple event?
>I don't know enough Perl to quite understand yours, but I do see that
>you handle errors better than this - I haven't figured out how to get
>the errors back from DoAppleScript yet.  Thank you for your example.
>I can see that will be handy.


here's one way:

sub  finder_script ($)
{
    my ($script) = @_;
    my ($ans);

    $ans = MacPerl::DoAppleScript(<<"    END_SCRIPT");
    try
        tell application "Finder"
                $script
            return ""
        end tell
    on error errStr
        return errStr
    end try
    END_SCRIPT
    # return 0/1 value just like rename, etc do
    # though the actual text is more useful for debugging
    if ($ans) {
        # while $! can return a number (errno) or string
        # depending on context, you can only assign a number to it
        #$! = strip_quotes $ans;
        return 0;
    } else {
        return 1;
    }
}


then you can go:

    $ans = finder_script <<"    END_SCRIPT";
        make alias file to $type \"$from\"
        move alias file \"$from alias\" to folder \"$tp\"
        set name of alias file \"$tp:$fn alias\" to \"$tn\"
    END_SCRIPT




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