Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Decoding a Binary file with fields created using COMP

0 views
Skip to first unread message

Steve Gill

unread,
Jan 11, 1997, 3:00:00 AM1/11/97
to

I'm trying to decode a binary file created using Cobol. The fields are
all compressed using COMP, so that the first field, a 13 digit code,
is 6 bytes long. Now using MS Access low level functions I can import
any specified byte and display it in decimal or hex. Hoever, the
figure it gives me for each byte just doesn't make sense, I'm used to
each byte being a max of 255. For example, bytes 1 to 5 are 0, and the
sixth byte in the file is 10000 odds displayed as decimal. Now I've
searched through all the documentation I can find and I cant find
anything about decoding the file when it is compressed.

Can anyone help, or point me in the right direction?

Thanks

Steve

Bill Wood

unread,
Jan 11, 1997, 3:00:00 AM1/11/97
to

If the select for the 13-digit field was

PIC S9(13) COMP-3

the result of putting the number 12345 in the field would result in the
following values for the 6 bytes:

00 00 00 00 12 34 5c

where c is the sign byte (assumed here to be trailing). This is at least
how I've always seen it. I hope this helps.


Steve Gill <st...@cepheus.demon.co.uk> wrote in article
<85299623...@cepheus.demon.co.uk>...

Neil Trotter

unread,
Jan 13, 1997, 3:00:00 AM1/13/97
to

In article <85299623...@cepheus.demon.co.uk>, Steve Gill said:

> I'm trying to decode a binary file created using Cobol. The fields are
> all compressed using COMP, so that the first field, a 13 digit code,
> is 6 bytes long. Now using MS Access low level functions I can import
> any specified byte and display it in decimal or hex. Hoever, the
> figure it gives me for each byte just doesn't make sense, I'm used to
> each byte being a max of 255. For example, bytes 1 to 5 are 0, and the
> sixth byte in the file is 10000 odds displayed as decimal. Now I've
> searched through all the documentation I can find and I cant find
> anything about decoding the file when it is compressed.
>
> Can anyone help, or point me in the right direction?

Steve,

Some hints:

o *If* you've got the Cobol which compiled the programs which created the
files, you will be able to write out data of known values, and deduce the
format. BUT: be aware that compiler options can sometimes alter data
representation (the ALIGN directive comes to mind for one) -- so be sure you
are using the same options.

o COMP doesn't mean Compressed -- it's an abbreviation of COMPUTATIONAL,
meaning binary. It doesn't matter how much you compress an 8-bit byte,
you'll still only be able to represent a maximum of 256 distinct values!

o Be aware that the byte-order is not always as you'd expect. The *only*
way to determine this is to examine known values (e.g. 1234567890123) in the
Access environment.

Good luck!


-- Neil.


Neil Trotter, Huddersfield, UK
phone: +44 (0) 1484 534420
mail: ne...@nook.demon.co.uk
WWW: http://www.nook.demon.co.uk


0 new messages