There are also three special functions to extract numeric values from a
Field string. They are:
CVI = Convert String to Integer number.
cvs = Convert String to Single Precision number.
CVD = Convert String to Double Precision number.
20 DEFDBL A-H
80 OPEN ....
90 FIELD£1,8 AS NUMBERS, etc
130 GET£1,6 ‘ie; READ record number 6
140 NUM=CVD(NUMBER$ )
Here record number 6 is read and the Field ‘NUMBER$’ is converted into a
Double Precision value that is stored in variable ‘’NUM’ for further
processing. Note the declaration of the precision of numeric variables in 20.
The main advantage of the use of CV and MK functions is that less space is
required in the records, and on disk.
EXTENDED FIELDS and ARRAYS.
Tt is often necessary to store a lot of Data in the Fields of one Record.
For example the amount spent per month on Petrol. It would be very tedious to
have to type in something like ....., 4 AS JAN$S, 4 AS FEBS etc. (It is also
convenient to restrict line lengths to less than 80 characters to allow as
much use as possible of the extended screen editing features of SYS/GEMINI
CP/M). Fortunately it is possible to continue FIFLD statements on to several
lines, and to use FOR-NEXT loops in their construction:–
10 DIM MTH$(11),DATESS(11),BALANCES(11),etc
20 MTH$(0)="JAN” :MTH$(1)="FEB”: ete
70 OPEN “R",£1, “SALARY. DAT”, 214
80 FOR X=0 TO 11
90 FIELD£1,20 AS NAME$,24 AS STREET$S,18 AS TOWN$S,8 AS POSTCODES
100 FIELD£1,70 AS DUMMY$,(12*X) AS SPACE$,4 AS BALANCES (X),8 AS DATESS(X)
110 NEXT X
This example is not so easy to understand.
Line 20 – The names of the months are stored in an array so that they can
be printed using a FOR-NEXT loop as desired later.
The file is OPEN’ed. It is assumed that it stores the Monthly
salary and Date of payment for the person named in the record. The
Record is 214 bytes long as will be shown.
Sets up Fields for the self evident bits of Data.There is not
sufficient room in 90 to continue unless a non-screen editable
line is entered. The Fields in line 90 occupy 70 bytes.
The first Field is a ‘dummy’ to ensure that all the Fields in
line 100 start later than Fields in line 90.As long as no Data is
LSET or RSET into the Field DUMMY$ then Data in the Fields of
line 90 is not corrupted. SPACE$ is another dummy, used as
Continue the loop until 12 ‘BALANCE’ and ‘DATE’ fields are set.