Link to home
Start Free TrialLog in
Avatar of PsychoKiller
PsychoKiller

asked on

Pascal 6 byte Real to VB

I need to convert files created with Pascal to something I can read with Visual Basic.  How can I convert the 6 byte REAL datatype in PASCAL to the Double type of Visual Basic?
ASKER CERTIFIED SOLUTION
Avatar of wireman
wireman

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PsychoKiller
PsychoKiller

ASKER

Wireman,

Thanks, but this is not what I needed.  The alogrithm is much more complicated than just moving the values into a long variable.  The sign bit, exponent, and mantissa need to be parsed from the 6 bytes of the Pascal real data type, and I am not sure what is where.

Thanks for responing anyway.

Karl
That is what I need to know to customize the function for you.

If you still program in Pascal, find out:
Upper limit
Lower Limit
Max number of decimal places
Max number of whole number places
Wireman,

I don't do Pascal.  VB and VC++ are my area's of expertise. (Oh yeah, IBM 370 Assembler, RPG II, COBOL, and REXX, but that was about 15 years ago :-)  Anyway, here are a few samples created by the Pascal program.  I would up the points on this for you but I don't know how.

Thanks,
Karl

Hex value    = Decimal Value
810000000000 = 1000
81A69BC42000 = 1001
814C37894100 = 1002

>>> How do you convert the 6 byte real values from Pascal to the double precision type of VB? <<<

Thanks for all the help guys.  I got it.  If you are intersted in the solution, drop me an e-mail.  It was a real bitch because VB has no bit shift operators, and multiplying by multiples of 2 caused overflow exceptions.  I will spend another few moments (when I get around to it) to clean it up a little more, but it works.

Thanks again,
Karl
VB doesn't have any bit shift operations, but you can use and/or with API to do those operations too.

here are some usefule API for memory operations

' Note: VarPtr was incorporated into the language at VB5.
#If Win32 Then
   Private Declare Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
   Private Declare Function VarPtr Lib "VB40032.Dll" (pAny As Any) As Long
#Else
   Private Declare Sub CopyMem Lib "kernel" Alias "hmemcpy" (Destination As Any, Source As Any, ByVal Length As Long)
   Private Declare Function VarPtr Lib "VB40016.Dll" (pAny As Any) As Long
#End If

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Declare Sub FillMemory Lib "kernel32" Alias "RtlFillMemory" (Destination As Any, ByVal Length As Long, ByVal Fill As Long)
Private Declare Sub ZeroMemory Lib "kernel32" Alias "RtlZeroMemory" (Destination As Any, ByVal Length As Long)

Private Declare Function EqualMemory Lib "ntdll" Alias "RtlCompareMemory" (Destination As Any, Source As Any, ByVal Length As Long) As Long