Re: Cobol convert program Job Request
- From: "Rick Smith" <ricksmith@xxxxxxx>
- Date: Thu, 22 Feb 2007 16:34:02 -0500
<jacodeguy@xxxxxxxxx> wrote in message
news:1172178058.861073.181220@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Feb 22, 2:06 pm, "Richard" <rip...@xxxxxxxxxxxx> wrote:
On Feb 23, 8:51 am, Louis Krupp <lkr...@xxxxxxxxxxxxxxxxxxxxxxx>
wrote:
The record matches the layout perfectly!
Micro Focus S9(4) COMP is two bytes binary
and 9V9(4) COMP is three bytes binary.
How do you fit a sign and four digits into two bytes? (Or am I being
unusually dense today?)
In binary (as stated). The value in 16 bit can be -32368 to 32367
which is a larger range than -9999 to 9999.
COMP (in this case) however is byte reversed compared to intel format
being big-endian.
I have some printouts of what the sketch should look like, I cannot
find the first record (pin 01-000-001-00), but I do have the second
(pin 01-000-006-00). Based on looking at the printout, I think the
first part should be like this:
01-000-006-00, A, -40, 16, 1, 11, 13, 33, 13, 49, 31, 49, 31, 53, 47,
53, 47, 27, 23, 27, 23, 33, 13, 33, 0, -2,
C I can do, and would love too, but a little rusty. The bytes and
strings I think I can get out, but I'm not sure about the S9(4) COMP
(two bytes reversed) thing.
if I have:
byte *buffer;
fread(buffer, 2, f);
// lets pretened I just read a comp, you previously said:
// "Just byte switch the COMP fields."
// How would I do that?
int x = (buffer[1] << 16) && buffer[0]; // something like this?
Just the reverse and a bit different.
int x = (buffer[0] << 8) && buffer[1];
I did it a bit differently. [Using C++, as a better C.]
See Get_PT_TwoByteComp, below.
-----
#include <stdio.h>
struct TwoByteComp {
unsigned char c[2];
};
struct ThreeByteComp {
unsigned char c[3];
};
struct {
unsigned char RecordDescriptor[2];
struct {
char PT_PROP_NO[20]; // not nul terminated
char PT_SEQ;
} PT_KEY;
struct {
struct {
TwoByteComp PT_X; // big-endian
TwoByteComp PT_Y; // big-endian
} PT_TABLE[200];
} PT_GRAPHICS;
TwoByteComp PT_END; // big endian
ThreeByteComp PT_SCALE; // big-endian
} PT_REC;
signed short Get_PT_TwoByteComp (TwoByteComp *comp) {
return (signed short) (comp->c[0]*256+comp->c);
}
double Get_PT_SCALE (ThreeByteComp *comp ) {
return (double) ((comp->c[0]*65536+comp->c[1]*256
+comp->c[2])/10000.0);
}
bool IsValidRecord (void) {
return ((PT_REC.RecordDescriptor[0]>>4)==4);
}
void main (void) {
printf ("%d\n", sizeof (PT_REC));
return;
}
-----
The output is 828, which is the size of the record
with the descriptor.
This might give you some ideas.
.
- Follow-Ups:
- Re: Cobol convert program Job Request
- From: jacodeguy
- Re: Cobol convert program Job Request
- References:
- Cobol convert program Job Request
- From: jacodeguy
- Re: Cobol convert program Job Request
- From: Richard
- Re: Cobol convert program Job Request
- From: jacodeguy
- Re: Cobol convert program Job Request
- From: Richard
- Re: Cobol convert program Job Request
- From: jacodeguy
- Re: Cobol convert program Job Request
- From: jacodeguy
- Re: Cobol convert program Job Request
- From: Louis Krupp
- Re: Cobol convert program Job Request
- From: Rick Smith
- Re: Cobol convert program Job Request
- From: Louis Krupp
- Re: Cobol convert program Job Request
- From: Richard
- Re: Cobol convert program Job Request
- From: jacodeguy
- Cobol convert program Job Request
- Prev by Date: Re: Cobol convert program Job Request
- Next by Date: Re: Cobol convert program Job Request
- Previous by thread: Re: Cobol convert program Job Request
- Next by thread: Re: Cobol convert program Job Request
- Index(es):
Relevant Pages
|