develooper Front page | perl.macperl.toolbox | Postings from September 2002

Re: [MacPerl-Toolbox] Help, I want to create folders...

Thread Previous
From:
Alan Fry
Date:
September 1, 2002 11:51
Subject:
Re: [MacPerl-Toolbox] Help, I want to create folders...
Message ID:
p05100300b99808c1cb4f@[158.152.146.73]
At 10:48 am -0500 01/09/02, Greenblatt & Seay wrote:
>Thanks Thomas! This code will come in very handy.
>
>At 12:56 PM +0200 2002/08/30, Thomas Wegner wrote:
>>>#! perl -w
>>use Mac::Navigation;
>>
>>$options = NavGetDefaultDialogOptions();
>>$options->message("What's up, Doc?");
>>$reply = NavChooseObject("", $options, undef, sub {1}) or die $^E;
>
>If I click on "Cancel" I get the error message "# User canceled the 
>query (OS error -128)" and the program quits. I find it more useful 
>to change the preceeding line to...
>    $reply = NavChooseObject("", $options, undef, sub {1}) or $err = "$^E\n\n";
>so that $err can be examined to see if it contains the word 
>"cancelled" so the program can continue.
>
>>for ($i = 0; $i++<$reply->count; ) {
>>    print $reply->file($i), "\n";
>>}
>
>There is nothing returned in the first loop when '$i' is '0'. It's 
>neat that the user can shift click to select multiple files or use 
>the 'Select All' menu item to select all files in the dialog.
>
>>(copied from the ChooseObjects.t test/example script)
>
>Where can I find ChooseObjects.t? I installed MacPerl 5.6.1r1 using 
>the wonderful web updater but according to Sherlock I don't have any 
>'.t' files.

Somehow I missed the beginning of this thread, but if the question is 
how to select existing or create new folders, the script below might 
be appropriate. It behaves sensibly when the 'cancel' button is hit.

In passing note the line "$options->location($pt);" which has the 
side effect of making the dialog movable, which "Inside Macintosh" 
strongly advises one to do.

Alan Fry

____________


#!perl -w
#18 Aug 2000 ajf@afco.demon.co.uk

use Mac::Navigation;
use Mac::Files;
use Mac::QuickDraw;
use strict;

my $pt = new Point(56, 74);

my $dir = FindFolder(kOnSystemDisk, kDesktopFolderType);
my $options = NavGetDefaultDialogOptions();
$options->location($pt);

$options->message('Choose a folder');
$options->windowTitle("FolderFinder");

my $reply = NavChooseFolder( $dir, $options, sub{1});

if (defined $reply) {
    for (1..$reply->count) { print $reply->file($_), "\n" }
}

NavDisposeReply $reply if defined $reply;

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About