Chapter
10
I
BASIC
Keywords
CVD, CVI, CVS
Function
CVD(8- byte string)
CVI(2-byte string)
CVS(4-byte string)
Converts string values to numeric values.
These functions restore data to numeric form after it is read
from the disk. Typically, the data has been read by a GET state-
ment and is stored in a direct access file buffer.
CVD converts an 8-byte string
to
a
double precision number.
CVS converts a 4-byte string to
a
single precision number.
CVI converts
a
2-byte string
to
an integer.
CVD, CVI, and CVS are the inverse
of
MKD$, MKI$, and
MKS$, respectively.
Examples
A#
=
CVD<GROSSPAY$)
assigns the numeric value
of
GROSSPAY$
to
the double precision
variable A#.
Sample Program
This program reads from the file
test.dat,
which is created in the
sample program for the MKD$, MKI$, and MKS$ functions.
1420 OPEN
"R",
1,
"te~t.dat",
14
1430
FIELD
1,
2
AS
I1$,
4
AS
I2$,
8
AS
13s
1440 GET
1
1450 PRINT CVI<Il$), CVS(I2$), CVD(I39)
1460
CLOSE
BASIC prints 3000, 3000.1 and 3000.00001.
Note:
GET without
a
record number tells BASIC to
get the
first
record from the file or the record follow-
ing the last record accessed.
131