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

[MacPerl] awww Shucks



So I had another brilliant idea.

I have a script, a droplet, that needs to have a file dropped onto it
for anything meaningful to happen.  (For alla y'all who're curious,
it's a souped-up twisted version of what was previously posted to this
list as select_by_regexp.)  So I had
if(@ARGV == 0) {
  print "Usage: [several lines of helpful blather]\n\n"; exit;
}
But then I realized the helpful Usage blather was altogether
duplicating a lot of the content of the POD I also wrote for this.
So I thought, how's about:
if(@ARGV == 0) {
  do_magic_to_open_myself_in_Shuck;   exit;
}

That way, the script not only /contains/ its own documentation, but
it'll also fling it at the user as needed.  So, toward that end, I
started fiddling with code for a script to open itself in Shuck:

=head1 NAME

Thang!!!!

=cut

use Mac::MoreFiles; # so's I can call FSpDTGetAPPL

die "WHERE AM I????\n" unless -e $0 and -f _ and -r _;

$shuck = FSpDTGetAPPL(scalar(&MacPerl::Volumes()), "\xb7uck"), "\n";
die "Where is Shuck??\n" unless $shuck and -e $shuck;
$pod = $0;
&MacPerl::DoAppleScript(
"tell application \"$shuck\"
	activate
	open file \"$pod\"
end tell"
);

__END__

So I save this to disk, run, and it works admirably.  !!Except!! when I
save it as a droplet, in which case it fails totally; it seems, not
surprisingly, that Shuck looks only in the data fork for POD content,
and the code for droplets is in the resource fork (in TEXT #128 in
fact).

But I waaaaaaant it to be able to work for droooopleeeeets toooooo!


So, I ask you all:  here are the solutions I can think of... what do
you think of these alternatives, and can you think of others?

Alternative 1: For some enterprising person who knows more about these
things than me to make Shuck look for POD in TEXT resource #128 when
fed a droplet (or, in fact, a CGI or runtime, since those too have
their code in TEXT #128).
In fact, I'm guessing only Murr can do this.

Alternative 2: For someone (I could do this with no problem) to write
code such that, if $0 is a droplet, the contents of its TEXT #128 will
be copied into a temp file, and then Shuck will be told to open that
temp file (but if $0 is a text file, then just tell Shuck to open $0). 
This code would be large enough (i.e., more than just a 3 or 4 lines)
that I'd write it up into a .pm, say Mac/Shuck.pm, whose public
functions would be, say, &shuck_myself and maybe
&shuck_file($foo) (where &shuck_myself would be basically a call to
&shuck_file($0), etc.).

Alternative 2B: like Alternative 2, except that instead of the copying
$0's TEXT #128 to a temp file, it'd write it into the (presumably
null) data fork of $0.  Somehow this doesn't seem such a hot idea,
tho.

Ideas?

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