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

RE: [MacPerl] Two-pass droplet?



> > my @files = @ARGV;
> 
> See, I though this was a good idea, too, but
> 
>   print "@ARGV\n";
> 
> saved as a droplet gives no output.

Well, yes, if you double click it. If you drop files onto it it will print
their names (concatenated, of course).

A better idea might be to check to see if $ARGV[0] is defined. If so,
someone dropped a file (or maybe more than one) onto the droplet. If not,
prompt the user for a file name. Here's an example:

#!perl

if (defined($ARGV[0]))
{
    $myfile = $ARGV[0];
}
else
{
    opendir(FOO,".") or die "Can't open current folder: $!";
    @list = readdir(FOO);
    close FOO;
    $myfile = MacPerl::Pick("Select a file:",@list);
}

MacPerl::Answer("The file you chose was $myfile.","Oh boy!");

__END__

It's probably not the world's best example, but it was here when I needed
it. :)

Hope this helps.

-- Creede

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org