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

Re: [MacPerl] Getting TEXT out or the resource fork



Chris Nandor <pudge@pobox.com> wrote:

>At 11.36 -0400 1999.07.27, Ben Brown wrote:
>>By biggest concern is the text.  I can get the handle, but I need to get the
>>actual text that is stored there.  How can I do this?
>
>   $text = $handle->get;
>
>Handles are documented in the Mac::Memory module.  Took me awhile to figure
>this out, too.  :)

So right, Chris!

You'll need both Mac::Memory and Mac::Resources.  I recalled when reading 
your question that I've held onto a script posted here that does 
something similar (actually it reads TEXT resource 256 from clipping 
files).  It's meant to be saved as a droplet.  This should give you a 
clearer idea of how to go about it.  Oooh, this also demonstrates who to 
check type and creator codes!  No wonder I held onto this!

#! perl -w

use Mac::Resources;
use Mac::Memory;

my($creator, $type) = MacPerl::GetFileInfo(@ARGV);

if (defined($type)) {
  if ($creator eq 'drag' and $type eq 'clpt') {
    $fileref = FSpOpenResFile(@ARGV, 1);
    if (defined($fileref)) {
      $reshand = Get1Resource('TEXT', 256);
      if ($reshand) { print $reshand->get() };
    }
    CloseResFile $fileref;
  }
}


# Fungal Parataxonomy                   Mycology Information (Mycoinfo)
# Webmaster, Staff Writer      **The World's First Mycology E-Journal**   
# <mailto:webmaster@mycoinfo.com>            <http://www.mycoinfo.com/> 
#
# First they ignore you. Then they laugh at you. Then they fight you.
# Then you win.                                     --Mohandas Gandhi


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