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

Re: [MacPerl] several dumb questions



John W Baxter <jwblist@olympus.net> writes:
>The machine name is found is 'STR ' resource -16413
>[...]
>I haven't been following the modernizations of MacPerl...I don't know how
>to read that 'STR ' (space significant) resource, particularly honoring the
>do not release.

OK, another opportunity to show off the Mac toolbox features:

#!perl
#
# Print name of the Machine as defined in Sharing Setup 
#
use Mac::Resources;
use Mac::Types;
use Mac::Memory;

$res = CurResFile();
UseResFile(0);
$name = Get1Resource('STR ', -16413);
print MacUnpack('STR ', $name->get), "\n";
UseResFile($res);

The only non-toolboxish construct in here is MacUnpack, defined in Mac::Types,
which is used here to translate the Pascal string into a Perl string. Oh
yes, and $name->get gets the contents of a handle as a data block.

Matthias

-----
Matthias Neeracher   <neeri@iis.ee.ethz.ch>   http://www.iis.ee.ethz.ch/~neeri
  "And that's why I am going to turn this world upside down, and make
   of it a fire so *bright* that someone real will notice"
                                -- Vernor Vinge, _Tatja Grimm's World_