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

Re: [MacPerl] GUSI.ph questions



Nick,
Looking at Chris & Vicki's _MacPerl Power & Ease_ pp 284-285:
	"Choose was used primarily for networking and GUI purposes.
         However, the Socket module and various Mac Toolbox modules
         are now recommended for these uses."

Such as (open ...:MacPerl Ÿ:lib:Mac:StandardFile.pm in Shuck):
	StandardGetFile FILEFILTER, TYPELIST
		Display a dialog prompting for an existing file.
as in:
	#!perl -w
	my ( $file_obj, $file_to_open_name );
	use Mac::StandardFile;
	$file_obj = StandardGetFile 0, 'TEXT';
	if ( $file_obj->sfGood() ) {
		$file_to_open = $file_obj->sfFile();
		open FIN, $file_to_open or die "opening <$file_to_open> $!";
		...
	}
see also _MPP&E_ pp 184-188 re StandardFile.

But to answer your questions, "@types" is an array with file type specifiers
(like 'TEXT'), and the starting working directory often is,
but sometimes is not, the directory that the script being executed is
found in.  To get to the directory that the script is to be found in:
	( my $path = $0 ) =~ s/^(.*:)[^:]+$/$1/;
	chdir $path or die "cannot go to <$path> $!";

-- Larry

At 8:07 PM -0800 11/19/99, Nicholas G. Thornton wrote:
>$prompt = "Select a file...";
>$default = ":";
>$file = MacPerl::Choose(
>     &GUSI::AF_FILE,
>     0,
>     $prompt,
>     &GUSI::pack_sa_constr_file(@types),
>     ($default ? &GUSI::CHOOSE_DEFAULT : 0),
>     $default);
>push @ARGV, $file;
>
>Given the above code which is basically what I got when I asked how to do
>what is does (I know that sounds bad). I have a few questions. One) what
>should $default be to assume the same directery as where the script is?
>two) what use is @types?
>
>e meas,
>--Nick

--
Regards, Larry F. Allen-Tonar <mailto:larryat@cts.com> +1 760/746-6464 (voice)
         Software/Firmware Designer
         P.O. Box 463072
         Escondido, CA  92046-3072
"Futuaris nisi irrisus ridebis.", Carlton in _The Road to Mars_ by Eric Idle



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