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

Re: [MacPerl] File select (ethical issue?)



>Nick asked
>How do you make the popup window to select a file. Like in every application
>when you say to open a file, and in "type_creator_changer.pl"?
>

Don't do it like in "type_creator_changer.pl". That program does do the job
as requested in the original posting. It asks the user to select a file
that already has the desired creator and type, then asks the user to select
a file or folder of files that should be changed to  that creator and type.
I sent it specifically for that purpose to do a particular chore, but with
the warning not to use examples from it since it was one of my first
MacPerl programs and, therefore, didn't use the cleanest, best, or easiest
coding techniques.

In other words, I'm glad you ased instead of looking there. I'll include
better code below.

This raises a somewhat ethical issue in my mind. Am I actually doing a
bigger disservice in the long run by supplying inefficient, inelegant, yet
effective code?

I sent "type_creator_changer.pl" to help solve a problem. I waited to see
how other folks responded to the origianl request but felt the added
ability of my program to change a directory of files all at once might be
benificial. If I had had to take the time to clean up the code I would
never have replied at all.

David Seay
http://www.mastercall.com/g-s



#!perl5

require "GUSI.ph";

$prompt="Select a file...";
$default=""; # designate a path to the initial directory for dialog
$file = MacPerl::Choose(&GUSI::AF_FILE, 0, $prompt,
&GUSI::pack_sa_constr_file(@types), ($default ? &GUSI::CHOOSE_DEFAULT : 0),
$default);
($creator,$type)=&MacPerl::GetFileInfo("$file");
print "$file\nCREATOR = $creator TYPE = $type\n";



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