At 1:43 PM +0100 4/11/2001, Alan Fry wrote:
>At 9:32 am -0400 10/04/01, peter furmonavicius wrote:
>>Hi. I have been trying to figure out how to determine the
>>application's "version" information from within MacPerl (i.e. the
>>info shown in the "Version:" field when you do a 'get info' on an
>>application). Thanks for any advice/help.
>>--
>
>Chris has already given a neat solution to the problem but I could
>not resist the temptation of applying Bart Lateur's unpacking
>technique (see a previous thread <[MacPerl] StyledText data into a
>record of text and styl>) as follows:
>
>#!perl -w
>use strict;
>use Mac::MoreFiles;
>use Mac::Resources;
>use Mac::Memory;
>
>my $rfd = FSpOpenResFile($Application{"Arch"}, 1);
>
>my $rsc = GetIndResource('vers', 1);
>my $got = $rsc->get;
>my @l = split(//, unpack("a7", $got));
>
>printf "Version number = %02.x\n", ord($l[0]);
>printf "Revision number = %02.x\n", ord($l[1]);
>printf "Revision stage = %02.x\n", ord($l[2]);
>printf "Build number = %02.x\n", ord($l[3]);
>printf "Language integer = %02.x\n", ord($l[4]);
>
>my ($vers, $size) = unpack("x7a@{[ord($l[6])]}a", $got);
>my ($info) = unpack("x@{[8+ord($l[6])]}a@{[ord($size)]}", $got);
>
>print "Abbreviated string = $vers\n";
>print "Get Info string = $info\n";
>
>CloseResFile($rfd);
>
>I'm not sure if this takes care of the case raised by Charles
>Albrecht this morning however.
>
>Alan Fry
These two lines should refer to 'u' (or the equivalent), rather than to
'x' in the sprintf.
printf "Build number = %02.u\n", ord($l[3]);
printf "Language integer = %02.u\n", ord($l[4]);
The revision number should really be unpacked into two values, so the
pack pattern may need a little tweaking.
-Charles Albrecht
[EMAIL PROTECTED]