Re: [MacPerl-Porters] MacPerl::DoAppleScript and $@
[email protected] (Chris Nandor) Wed, 28 Nov 2001 13:15:12 -0500
| Newsgroups | perl.macperl.porters |
|---|---|
| Message-ID | <p05100300b82ad0a1ec6f@[10.0.1.177]> |
At 17:40 +0100 2001.11.28, Axel Rose wrote:
>Is there any general guideline in using $!, $^E and $@?
>When are they blanked out? Before each eval, system() or
>system() like operation?
$@ is blanked out when eval is called, or any other time something might
set it. :-) This normally isn't a problem, though. Just something to be
aware of.
> if( !defined MacPerl::DoAppleScript( "da" ) ) { die "dada" }
>fit's my needs.
I am not entirely sure it is entirely reliable; that is, it returns undef
under two conditions:
* The script does not execute
* The script result cannot be coerced into text
I am not sure what might cause the latter condition, so I can't say that
!defined is entirely reliable.
>Could $@ contain the same messages the Script Editor would return
>when trying to run a faulty script?
That is exactly what it does do with these changes.
#!perl -w
MacPerl::DoAppleScript('tell app "Finder" to open folder "blargh"');
warn $@ if $@;
MacPerl::DoAppleScript('dasd asd asd');
warn $@ if $@;
Returns:
# Finder got an error: Can't get folder "blargh".
File 'Dev:Pseudo'; Line 3
# A identifier can't go after this identifier.
File 'Dev:Pseudo'; Line 5
--
Chris Nandor [email protected] http://pudge.net/
Open Source Development Network [email protected] http://osdn.com/