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

Re: [MacPerl] Simple Open Dialog



At 15.50 -0500 1998.11.24, jason white wrote:
>#!perl
>
>$show_dialog	= "tell application \"Finder\"\n";
>$show_dialog.=		"activate\n";
>$show_dialog.=	"try\n";
>$show_dialog.=	"set file1 to choose file with prompt \"Select a file:\"\n";
>$show_dialog.=	'on error -- e.g. user cancelled' . "\n";
>$show_dialog.= "return\n";
>$show_dialog.= "end try\n";
>$show_dialog.= "end tell\n";
>
>MacPerl::DoAppleScript($show_dialog);

I think you might prefer:

$show_dialog = <<EOS;
tell application "Finder"
    activate
    try
        set file1 to choose file with prompt "Select a file:"
    on error -- e.g., a user cancelled
        return
    end try
end tell
EOS

MacPerl::DoAppleScript($show_dialog);



>Any way to have them share variables...namely the path name that is
>returned in the AS function?  Looking at the on-line book hasn't turned up
>any results thus far.

Sure it does.  Page 248.

  my $file = MacPerl::DoAppleScript($show_dialog);
  print $file;


>I've thought of having AS push it to the Clipboard
>and MacPerl getting it from ther (the path that results), but don't want to
>go there quite yet.

See the MacPerl book chapter 12, pp. 177-8 for accessing the Clipboard from
MacPerl.

For that matter, see chapter 13, pp. 184-8 for info on using Mac::StandardFile.

You might want to buy the book to keep it all handy.  :)

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

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