Thanks to John Penny for his thoughts.
Yesterday , I posed the question how to translate between
VB's complex numeric data types (Single and Double)
and HP native Cobol numerics (COMP SYNCs) .
Here's what I eventually did based on his idea - just to prove the concept.
Since I had already managed to translate Longs and
Integers into Cobol numerics then I simply converted
the VB double value to a Long integer by mutiplying it by 10 repeatedly
and then sent the cobol program the Long value plus an indicator of how many
times the cobol program would need to divide by 10 to get
back to the original Packed value.
Here's a few code fragments to explain all - No error
checking at present - as I said I was just trying to prove a theory.
Dim do_double As Double
do_double = 987.654321
sendbuff.cosendme = ConverttoCobol(do_double)
Private Function ConverttoCobol(doInputDouble As Double) As COBOLTRANSPORT_type
'
' a crude multiply up - longer term will need to work out multipier
' and add error checking
'
ConverttoCobol.cobol_multiplier = 1000000
ConverttoCobol.cobol_value = Round(doInputDouble * 1000000)
End Function
Type COBOLTRANSPORT_type
cobol_value As Long
cobol_multiplier As Long
End Type
The cobol program will see the two long values as PIC 9(18) COMP SYNC
once they have been suitably byte swapped.