At 01.27 -0500 1998.11.25, Brian McNett wrote: >>I'm just lurking here, but still, is it that I'm missing something or the >>only way to have a simple dialog to choose a file or a folder in MacPerl >>is either to call AppleScript/Frontier, or to call directly the Mac ToolBox? >> >>I though that Chris N. was working on a package that was going to make >>much more easier that kind of things. Sorry if this question have already >>been answered or is very obvious. > >These are two seperate items AFAIK. Actually, though, I did post a skeleton package some time ago that can simplify opening of files and choosing folders, etc. The idea would be that this would provide a generic dialog box, and would use Mac::Navigation if present, or Mac::StandardFile is not. Then a programmer could just type: get_file(PROMPT, DEFAULT, TYPES); # TYPES is array ref get_folder(PROMPT, DEFAULT); save_file(PROMPT, DEFAULT); Here is my first attempt from awhile back that just implements the first function. I don't claim this is the best way to do it, but I think this might be a good project for someone else (with some time and an itch to scratch) to take on. package Mac::GetFile; use Mac::Files; use Exporter; use vars qw(@EXPORT @ISA $VERSION); @ISA = qw(Exporter); $VERSION = 1.00; @EXPORT = qw(get_file); #-----------------------------------------------------------------# =pod =item get_file(PROMPT, DEFAULT, TYPES); =cut sub get_file { my($text, $default, $types, $file) = @_; if (eval {require Mac::Navigation}) { my($options, $nav); Mac::Navigation->import(); $options = NavGetDefaultDialogOptions(); $options->message($text); $options->windowTitle($text); local($^W) = undef; $nav = NavGetFile($default, $options, bless({}, 'NavTypeListHandle'), 0, 0, sub{ return unless (my $ft = $_[1]->fileInfo->finderInfo->fdType); return 1 if ($_[1]->isFolder()); foreach my $type (@$types) {return 1 if $ft eq $type} return; # I want to do this a better way but cannot get # TYPELIST to work in a way I like } ); return if (!$nav || !$nav->file(1)); $file = $nav->file(1); } else { require Mac::StandardFile; my($get); Mac::StandardFile->import(); $get = StandardGetFile(undef, 0); return if (!$get->sfGood()); $file = $get->sfFile(); } return $file; } #-----------------------------------------------------------------# __END__ -- 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