At 09.02 -0500 1999.03.23, Paul J. Schinder wrote: >On Tue, Mar 23, 1999 at 01:37:41PM +0000, Peter Westlake wrote: >} I drop a file onto the app's icon, and it works if I use MPW to >} invoke the app by its path, with the filename as a parameter. But >} life would be much simpler for me if I could just call this app >} from a Perl script. MacPerl doesn't have system(), so I'm trying >} to use AppleScript to call the app, using "launch" and "open file". > >No, but modern MacPerl can send an AppleEvent directly, and Chris >Nandor has been working to make this much easier to do than it is by >using only the stuff that comes with MacPerl. MacPerl does have system() if you have ToolServer installed, though. >} This is in a Perl script running in MacPerl 5.2.0r4, just to confuse >} matters. Now, sometimes it works, but sometimes the app puts up its >} interactive window, as if it hadn't been given a file to open. >} >} Let's just check that I understand how all this is meant to work, >} since I've never written a Mac program in my life! I gather that >} dragging a file onto an application is implemented by the Finder >} starting the application and sending it an 'odoc' AppleEvent. > >That's the way I understand it happens. Not quite. When you open from the Finder (such as with a droplet), the Finder is the one getting the odoc event. It basically would look like this using Mac::AppleEvents::Simple: use Mac::Files; use Mac::AppleEvents::Simple; # code passes ... do_event(qw[aevt odoc MACS], # aevt class, odoc event, MACS app id (Finder) q"'----':alis(@@), usin:alis(@@)", NewAliasMinimal($file), NewAliasMinimal($app)); Or in AppleScript: tell application "Finder" open alias myfile using alias myapp end tell This is different than: tell application "MacPerl" open alias myfile end tell But since it seems you are just trying to populate @ARGV, I would use the Mac::StandardFile package. use Mac::StandardFile; if (!@ARGV) { my $reply = StandardGetFile(0, '') or die $^E; die $^E if !$reply->sfGood; push @ARGV, $reply->sfFile; } If you want more than one file, you can wrap it in another dialog: use Mac::StandardFile; if (!@ARGV) { my $sf_done; while (!$sf_done) { my $reply = StandardGetFile(0, '') or die $^E; die $^E if !$reply->sfGood; push @ARGV, $reply->sfFile; $sf_done++ unless MacPerl::Answer('Select another file?', qw(OK Cancel)); } } -- 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 macperl-request@macperl.org