Re: Cobol convert program Job Request



On Feb 22, 3:34 pm, "Rick Smith" <ricksm...@xxxxxxx> wrote:
<jacode...@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.

Sweet! Yes, that seems to work. Only little bug was this line:

signed short Get_PT_TwoByteComp (TwoByteComp *comp) {
return (signed short) (comp->c[0]*256+comp->c);
}

should be:
return (signed short) (comp->c[0]*256+comp->c[1]); //with the [1]

Wow, I have not done it all yet, but got the pin and the first x,y. I
think I'm golden.

Thank you all very very much. Richard and Rick, I'd love to pay you
back. If you'd like to split the $100 please email me at andy at
camavision.com where I can send the check. Or if you had a wish list
online someplace just let me know. Or, if there is anything else I
can do to return the favor.

Thanks again,

-Andy

.



Relevant Pages