Help!! Converting Programs From Basica 
Author Message
 Help!! Converting Programs From Basica

My company has many programs written on Basica (Yeeks!).

I have converted all of them to Visual Basic. (rewritten them)

I am however having a problem with one crucial part. The Basica
programs read from randon access files. Something like this:

OPEN ......
FIELDS .......,8 AS $N1,...
....
....
NUMBER = CVD(N1)

NUMBER would then contain the correct value. I have tried everything I
know of to get the right value into NUMBER in Visual Basic but cannot
seem to get it to work.

Eg. The hex dump of a number is 00 00 00 00 00 08 68 8F
This number is read in as 400.00 in Basica but in
Visual Basic I get something like 2.13E-317 (garbage).

Any suggestions to help me resolve this would be appreciated. Thanks.



Sat, 27 Mar 1999 03:00:00 GMT  
 Help!! Converting Programs From Basica



Quote:
>My company has many programs written on Basica (Yeeks!).
>I have converted all of them to visual basic. (rewritten them)
>I am however having a problem with one crucial part. The Basica
>programs read from randon access files. Something like this:

>OPEN ......
>FIELDS .......,8 AS $N1,...
>....
>....
>NUMBER = CVD(N1)

>NUMBER would then contain the correct value. I have tried everything I
>know of to get the right value into NUMBER in Visual Basic but cannot
>seem to get it to work.

>Eg. The hex dump of a number is 00 00 00 00 00 08 68 8F
>This number is read in as 400.00 in Basica but in
>Visual Basic I get something like 2.13E-317 (garbage).

>Any suggestions to help me resolve this would be appreciated. Thanks.

The knowlege base says to:

How to Emulate MKI$ and CVI in VB Using Windows HMemCpy
Article ID: Q87970
Revision Date: 21-JUN-1995

The information in this article applies to:

 - Standard and Professional Editions of Microsoft Visual Basic for
   Windows, versions 2.0 and 3.0
 - Microsoft Visual Basic programming system for Windows, version 1.0

SUMMARY

Visual Basic for Windows does not support the MKx$ and CVx family of
conversion functions found in
earlier versions of Microsoft QuickBasic and Basic Professional Development
System (PDS) for MS-DOS.
However, you can write functions that provide this support using the
hmemcpy API routine provided by
Windows version 3.1.

This article provides example routines that simulate the MKI$, MKL$, MKS$,
MKD$, CVI, CVL, CVS, and
CVD functions.

MORE INFORMATION

The MKx$ functions convert numeric values to strings by placing the ASCII
value of each byte that
represents the numeric value into a string.

Function Description

MKI$       Converts an integer to a 2-byte string
MKL$       Converts a long-integer to a 4-byte string
MKS$       Converts a single precision variable to a 4-byte string
MKD$       Converts a double-precision variable to an 8-byte string

The CVx functions convert strings created with the MKx$ functions back into
numeric values.

Function Description

CVI        Converts a 2-byte string created with MKI$ to an integer
CVL        Converts a 4-byte string created with MKL$ to a long integer
CVS        Converts a 4-byte string created with MKS$ to a single-
           precision number
CVD        Converts an 8-byte string created with MKD$ to a double-
           precision number

The hmemcpy API function can be used to emulate these functions as
demonstrated in the example
below. Note that the hmemcpy API function is not provided with Windows
version 3.0, so the example
below requires Windows version 3.1.

The hmemcpy routine copies bytes from a source buffer to a destination
buffer. You can use this
routine to copy the value of each byte in a numeric value to a
corresponding byte in a string to
emulate the MKx$ functions. Similarly, you can use the same technique to
copy the bytes from a
string to a numeric value, to emulate the CVx functions.

  NOTE: The hmemcpy routine requires the addresses pointing to the actual
location of the data to
  be copied from and written to. Therefore, it is necessary to pass strings
by value (ByVal) in
  order to pass the location of the string data, as opposed to passing the
location of the string
  descriptor. Similarly, it is necessary to initialize the string size by
assigning the string to
  an appropriate number of characters.

To use the following routines in your Visual Basic for Windows

application, you must Declare the hmemcpy routine. Add the

following code to the general declarations section of the form:

   ' Enter the following Declare statement on one, single line.
   Declare Sub hmemcpy Lib "kernel" (hpvDest As Any, hpvSource As Any,
      ByVal cbCopy As Long)

   Function MKI$ (x As Integer)
      temp$ = Space$(2)
      hmemcpy ByVal temp$, x%, 2
      MKI$ = temp$
   End Function

   Function CVI (x As String) As Integer
      If Len(x) <> 2 Then
         MsgBox "Illegal Function Call"
         Stop
      End If
      hmemcpy temp%, ByVal x, 2
      CVI = temp%
   End Function

   Function MKL$ (x As Long)
      temp$ = Space$(4)
      hmemcpy ByVal temp$, x&, 4
      MKL$ = temp$
   End Function

   Function CVL (x As String) As Long
      If Len(x) <> 4 Then
         MsgBox "Illegal Function Call"
         Stop
      End If
      hmemcpy temp&, ByVal x, 4
      CVL = temp&
   End Function

   Function MKS$ (x As Single)
      temp$ = Space$(4)
      hmemcpy ByVal temp$, x!, 4
      MKS$ = temp$
   End Function

   Function CVS (x As String) As Single
      If Len(x) <> 4 Then
         MsgBox "Illegal Function Call"
         Stop
      End If
      hmemcpy temp!, ByVal x, 4
      CVS = temp!
   End Function

   Function MKD$ (x As Double)
      temp$ = Space$(8)
      hmemcpy ByVal temp$, x, 8
      MKD$ = temp$
   End Function

   Function CVD (x As String) As Double
      If Len(x) <> 8 Then
         MsgBox "Illegal Function Call"
         Stop
      End If
      hmemcpy temp#, ByVal x, 8
      CVD = temp#
   End Function

Peter Mikalajunas

http://www.xnet.com/~kd9fb



Sun, 28 Mar 1999 03:00:00 GMT  
 Help!! Converting Programs From Basica

Quote:

> My company has many programs written on Basica (Yeeks!).

> I have converted all of them to visual basic. (rewritten them)

> I am however having a problem with one crucial part. The Basica
> programs read from randon access files. Something like this:

> OPEN ......
> FIELDS .......,8 AS $N1,...
> ....
> ....
> NUMBER = CVD(N1)

> NUMBER would then contain the correct value. I have tried everything I
> know of to get the right value into NUMBER in Visual Basic but cannot
> seem to get it to work.

> Eg. The hex dump of a number is 00 00 00 00 00 08 68 8F
> This number is read in as 400.00 in Basica but in
> Visual Basic I get something like 2.13E-317 (garbage).

> Any suggestions to help me resolve this would be appreciated. Thanks.In Basica Microsoft used a diferent format for single and double numbers.

You should use CVDMBF(NI) in order to get the number right.

Ziv Tal.



Wed, 31 Mar 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How do I convert BASICA programs?

2. Problem converting from basica to gwbasic

3. Volunteer to convert my BASICA/GWBASIC into ascii

4. Anyone have a qbasic or basica Terminal Program ????

5. Problem with legacy Basica programs

6. BASICA PROGRAM

7. BASICA PROGRAM

8. BASICA Init. Program

9. Modifiying Programs saved in BASICA with ,P

10. Help: converting VB3 binary text based program to to VB5 database

11. Help : Converting VB 3.0 Program to VB 5.0

12. converting C program to VB4 - 16 bit (HELP)

 

 
Powered by phpBB® Forum Software