PureBytes Links
Trading Reference Links
|
I am currently using Metastock Version 5.1
I have been trying to read the Metastock Binary . Dat files directly from
32 bit Microsoft Visual Basic.
I have followed a crib sheet given to me by a friend from an old DOS
Metastock Manual which details how to read Metastock files into GW or Quick
Basic, but unfortunately the functions CVI( ), CVS( ) are not directly
supported in Visual Basic
Microsoft do have a .dll which provides CVS( ), CVL( ) but not CVI( )
functions - this works fine in 16 bit Visual Basic 3, and the CVI function
can be emulated using the HMemCpy function from the "kernel.dll" provided
with windows 3.1. The dll is available from the Microsoft File Library as a
self exploding zip, "mbf2ieee.exe"
In VB 3 .1 I can get all the functionality I need by combiming the two
different techniques and in this way I can read the .dat files correctly.
However sadly Microsoft do not provide an updated 32 bit version of the
mbf2ieee.dll so in order to read the MBF files I have tried to use the
Microsoft's suggested emulation of CVS( ) using the 32 bit equivalent of the
HMemCpy functions. Both 16 and 32 bit functions are listed below.
Unfortunately, both the emulated CVS functions misinterpret the MBF numbers
in exactly the same way, yielding for example:-
True number Misinterpreted Number
" 930112" = -1.1464515535577E-26
" 970722" = -1.1965060105891E-26
Does anyone have any suggestions as to how to correct this ?
Here are the functions that are causing me problems:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16 Bit CVI and CVS Emulation using HmemCpy
Ref : How to Emulate MKI$ and CVI in VB Using Windows HMemCpy
Microsoft Knowledge Base :Q87970 >
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Declare Sub hmemcpy Lib "kernel" (hpvdest As Any, hpvsource As Any, ByVal
cbCopy As Long)
Function CVI (x As String) As Integer
Dim temp%
If Len(x) <> 2 Then
MsgBox "illegal function call on CVI"
Stop
End If
hmemcpy temp%, ByVal x, 2
CVI = temp%
End Function
Function CVS (x As String) As Single
Dim temp!
If Len(x) <> 4 Then
MsgBox "Illegal Function Call"
Stop
End If
hmemcpy temp!, ByVal x, 4
cvs = temp!
End Function
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32 Bit Equivalent of the above functions
Ref : Win32 Replacement of HMemCpy Functions
Microsoft Knowledge Base Article ID: Q129947
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (hpvDest As Any,
hpvSource As Any, ByVal cbCopy As Long)
Function CVI(x As String) As Integer
Dim temp as integer
If Len(x) <> 2 Then
MsgBox "Illegal Function Call"
Stop
End If
CopyMemory temp%, ByVal x, 2
CVI = temp%
End Function
Function CVS(x As String) As Single
Dim temp As Single
If Len(x) <> 4 Then
MsgBox "Illegal Function Call"
Stop
End If
CopyMemory temp, ByVal x, 4
CVS = temp
End Function
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
***********************************************************************
Matt Bounds
mbounds@xxxxxxxxxxxxx
***********************************************************************
|