Re: Version of a .4go?
Posted in 1998
Jonathan Leffler wrote: > > jhatfiel wrote: > > Does anyone know how to get the P-Code version of a .4go? > > Byte one (counting from one) should be hex 0x01. > The next two bytes are the p-code version number > in a short integer, MSB first. So, given that, (thanks, Jonathan!), a script like this will print out the pcode version of a file for you: ------------------------------- #!/usr/bin/ksh # CMcG 10 Nov 98 # pcode_vers - print pcode version of a 4gi/4go file if [ "$1" != "" ]; then fname=$1 else echo read fname?'Please enter the program name > ' fi if [ a$fname = "a" ]; then echo "\\nNo program name supplied, exiting...\\n" exit fi if [ ! -r $fname ]; then echo "\\nFile can't be read, exiting...\\n" exit fi od -h $fname | head -1 | cut -c12,13,15,16 | awk 'BEGIN { init() } { a=substr($1,1,1) b=substr($1,2,1) c=substr($1,3,1) d=substr($1,4,1) vers = decs[a] * 4096 + decs[b] * 256 + decs[c] * 16 + decs[d] print "The pcode version of", fname, "is:", vers } function init() { split("1 2 3 4 5 6 7 8 9 a b c d e f", octs) for (name in octs) { x=octs[name] decs[x]=name } } ' fname=$fname ------------------------------- -- ______________________________________________________________________ | Colin McGrath cmm@trac3000.ueci.com | | Raytheon Engineers & Constructors, Inc. (215) 422-4144 | | Phila, PA, USA | | Any opinions I state are my own and not necessarily of my employer | |____________________________________________________________________|