HP3000-L Archives

March 2000, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Tony Summers <[log in to unmask]>
Reply To:
Tony Summers <[log in to unmask]>
Date:
Tue, 28 Mar 2000 15:24:55 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (43 lines)
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.  

ATOM RSS1 RSS2