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

[MacPerl] Prompt for folder?



Hello,

	I've been busy building some utility modules and I have a question: How do you
prompt for a folder rather than a file? I've written a work-around (select a
file in a folder and the folder is what I take), but it'd be nice to have a
more elegant solution.

	To better illustrate what I mean, I've included said utility. Feel free to use
it or play around with it. It likes to be in your search path in a folder
called "ISINTRA" (dumb name, but I couldn't think of a better one that hasn't
been taken!). It doesn't need to be, but the code examples all assume that it
is.

	For those of you who are interested in this and in the other utilities I'm
creating, feel free to let me know!

-josh

PS. Don't forget to let me know if I've done something stupid or if there are
any bugs!
-----------------------------------------------------------------
                       Open Learning Agency
4355 Mathissi Place, Burnaby, B.C. Canada, V5G 4S8 (604) 431-3000

package Folder;=head1 NAMEISINTRA::Folder=head1 SYNOPSIS  use ISINTRA::Folder;   $folder = new Folder;                 # will prompt for folder  $folder = new Folder("folder:folder") # will attempt this value  $folder = new Folder(@ARGV)           # handy for a droplet     =head1 DESCRIPTIONFolder.pm was written to handle a variety of ways that a script canopen and use a folder. I have some scripts and droplets that openfolders or start at folders and recurse through them. I wrotethis as a common code base.=head1 NOTESIf you cancel a dialog or pass a bad path, $folder will be "0"rather than an object reference.If no proper folder is specified, Folder.pm will bring up a dialog to select a folder. Actually, the dialog prompts fora file inside the desired folder - I don't know how to selecta folder by itself.This module cannot handle VOLUMES. Folders only, please! Volumesseem to work a whole different way.=cut$folder = ":";sub new {   my($cl!
ass,@args) = @_;   my $self = {};   bless $self, $class;      my($result) = $self->_init(@args);      return ($result) ? $self : 0;}sub _init {   my ($self, @args) = @_;      if (@args) {      my($folder) = $args[0];      if(-f $folder) {         $folder =~ s/:[^:]*$//;  # get rid of any file info      }      if (!(-d $folder) or ($folder =~ /[^:]:$/) ){         return 0;      }      

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