Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Have a number of GWbasic (BASCICA) programs using single precision number stored in 4 bytes in random files. Am now converting to VB but wish to retain backward compatibility with the old DOS programs. GW stored integers work OK in VB but not the single precision. Does anybody know how to do the conversion or at least how the numbers are stored in GW so I can do my own conversion.

Thanks for the reply I know that MKS$ and CVS handle single precision to and from string format in GWBasic but how do you convert a single precision number stored in a file by GWB using VB to retreive it.
Perhaps the code below will illustrate. Take this bit of GW code
10 OPEN PATH$+"CHEMICAL"FOR RANDOM ACCESS READ WRITE SHARED AS 2 LEN=1200
20 FIELD 2,4 AS ANUMBER$
30 LSET ANUMBER$=MKS$(200)
31 PUT 2,1
32 GET 2,1
33 PRINT CVS(ANUMBER$)
40 END
The number I get back is naturally 200. The following VB code however gives me -6.018531E-34 when addressing the same file
Private Type Chemicals
ANumber As Single
X As String * 1196
End Type
Private Chemicals As ChemicalsPrivate Sub Command1_Click()
Open Path & "A:CHEMICAL" For Random As 1 Len = 1200
Get 1, 1, Chemicals
Print Chemicals.ANumber
End Sub
That is the problem

You have to the same conversion in VB also MKx$ before writing and CVx after reading.
Also you probably can't define A as NUMBER, it has to be a string that is to be converted.

mks$ and mksmbf$ use different number formats. As does their complements cvs and cvsmbf. It is best to use the manual for examples and make sample programs to test. My response 2 refers to the wrong ones. I haven't programmed in GWBASIC since the compilers were produced. I have just used a little more space and stored all numbers as strings. (easier to visually read the data files, too many versions of BASIC's)

![]() |
Executable of VC.NET
|
Batch to compare and move...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |