Hi Matt

Seems I remember that packed data looks the same, no matter what the decimal places. Decimal place is defined somewhere else and applied to the packed data.

So you could MOVE to a packed 30,9 to get the value into a packed field (if you want to use fixed-from opcodes). Or you could define a DS with overlaid subfields - one is the 30,9 packed, another starting at the same place is a 16-character field initialized to x'00'. Then substring the packed data at the end. I assume you'll find the attributes from the data area, in which case you then multiply as needed to get the right value - or you could substring into the character field at the appropriate starting point, replace the "sign" nybble with 0, and put that "sign" nybble on the last byte.

Multiplying will be easier to code - probably a little slower, but these days, maybe not an issue. The other should be faster but harder to write.

I think - I'm on vacation, so just dallying about the list!

Vern

On 4/23/2012 11:04 AM, Matt Lavinder wrote:
There is a strong possibility I am over complicating this so before I spend
too much time on this I wanted to ask...

I am trying to write a generic procedure to retrieve a data area that is a
decimal value. Currently, we have to adjust the procedure every time we
need to handle a new size, and then we have to add variables and specific
code for that size.

I am trying to use the QWCRDTAA to retrieve the value and ultimately want
return a decimal of 30p 9 that contains what ever was found in the data
area. Problem is, the data comes back as hex from QWCRDTAA (the raw
decimal data). Obviously I could just MOVE the data if I wanted to define
decimals of all possible sizes, but then I am back to the very thing I am
trying to avoid.

As a part of my procedure, I pass in the definition of the data area, so I
know that at run time. What is the quickest way to get that raw/hex data
into a decimal variable I can work with? If you were to put the logic I am
looking for into a procedure, the prototype to convert this character/hex
data would need to look something like this:

D HexToPacked pi 30p 9
D pHex 2000a
D pDecLen 5i 0
D pDecPrecision 5i 0

Just remember, the character data here does not contain '20.345'. If it
did, it would be easy. The data here is in hex and I need to get it to
packed. Essentially I am want to moving data into a packed field where
size is not known at compile time. As I said, I am probably over
complicating this.

Thanks.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].