Specifications

130
8.2.5 Programming for Data Files
Input/Output for Numeric Data
- To write numeric data into a data file:
It is necessary to use the
STR$ function for converting the value of a numeric expression
into a string.
To write -12.56 into a data file, for example, the field length of at least 6 bytes is required.
When using the
FIELD statement, designate the sufficient field length; otherwise, the data
will be lost from the lowest digit when written to the field.
- To read data to be treated as a numeric from a data file:
Use the
VAL function for converting a string into a numeric value.
Data Retrieval
The SEARCH function not only helps you make programs for data retrieval efficiently but
also makes the retrieval speed higher.
The
SEARCH function searches a designated data file for specified data, and returns the
record number where the search data is first encountered. If none of the specified data is
encountered, this function returns the value 0.
Deletion of Data Files
The CLFILE or KILL statement deletes the designated data file.
CLFILE Erases only the data stored in a data file without erasing its directory informa-
tion, and resets the number of written records to 0 (zero) in the directory. This
statement is valid only to opened data files.
KILL Deletes the data stored in a data file together with its directory information.
This statement is valid only to closed data files.
Program sample with the
CLFILE statement
OPEN "work2.DAT" AS #1
FIELD #1,1 AS a$
CLFILE #1
CLOSE #1
Program sample with the KILL statement
CLOSE
KILL "work2.DAT"