Re: [MacPerl-Modules] "Version" info
[email protected] (Charles Albrecht) Tue, 10 Apr 2001 11:26:39 -0600
| Newsgroups | perl.macperl.modules,perl.macperl.toolbox |
|---|---|
| Message-ID | <p0501040eb6f8f129178d@[12.86.9.20]> |
At 12:39 PM -0400 4/10/2001, Chris Nandor wrote: >At 09:32 -0400 2001.04.10, 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. > >This is what I came up with. Have fun! Note that you can do this with the >app open, since we open the resource in read-only mode. I would make one change. ># numeric version >my @num = split //, sprintf "%x", ord $data[1]; >printf "%x.%d", ord $data[0], $num[0]; >printf ".%d", $num[1] if $num[1]; >printf "$r%x", ord $data[3] if $r ne 'f'; >printf "\n"; I'd change the next to the last line to: printf "$r%u", ord $data[3] if $r ne 'f'; While the version number is a binary coded decimal (ranging on one byte from 0-99), the non-release stage isn't (it ranges from 0-255). ResEdit gets this wrong in every version I've seen. Resourcerer 2 and later interpret it correctly. See Apple Technote 1132 for further information: http://developer.apple.com/technotes/indexes/numberindex.html?number=1132 -Charles Albrecht [email protected]