From: "Braun Brelin" <[log in to unmask]>
> Oops, that's supposed to be a "4", not an 8. basically, the keys are
usually
> 7 digits long (like 1951423). I'm unsure if I'm supposed to add in the
"01" or
> not, so, I've tried it both ways, neither of which works...
>
> Braun Brelin
Your saying "4", not 8, above confuses me... I'm not sure what it refers
to.
From your initial message I understood that the key is 8 bytes long, the
first byte is ascii "0" (hex 30, decimal 48), the second byte is "1" (hex
31, decimal 49), followed by 6 bytes encoding a 12-digit decimal number in
unsigned packed decimal format.
If you're not sure, you can check the data that is currently in the
database. E.g., in SUPRTOOL you can do a LIST HEX. I'm not sure if you can
do that in QUIZ, but you can save a record in a file using QUIZ, then do an
FCOPY IN=file;OUT=;HEX to see the bytes.
If I understand correctly, then this code will work:
sub packdec {
my ($item, $length) = @_;
$item = ('0' x ($length - length($item))).$item;
return pack("H$length",$item);
}
my $key = "01" . packdec(1951423, 12);
This will produce an eight byte string, where the bytes written out in hex
are:
30 31 00 00 01 95 14 23
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|