Functions

BASIC-SO

DSKF

The DSKF function returns the number of 128-byte sectors that are free on the specified disk. The examples below signify that there are 50* 128, or 6.4 kilobytes of free space on disk 1.

DSKF (drive number)

PRINT DSKF (1) 50

OK

EOF

The EOF function detects when the end of the file is reached when reading a sequen- tial data file. If there are no more data in the file, EOF returns a -1, indicating TRUE. At any other time, EOF will return 0, indicating FALSE. If the file is not open, an error results.

EOF (file number)

10OPEN "1",1, "[F1: PROGRAM]

20IF EOF(1) THEN 60

30LINE INPUT #1, A$

40PRINT A$

50GOT020

60END

ERL

The ERL function returns the number of the line in which the last error took place. It is normally used after an ON ERROR GOTO ... error trapping routine.

ERL

The program below uses the error-trapping instruction in line 10 to print the error description in line 40. This line also contains the function ERR, which displays the code number of the error. In this example the error is division by 0, which has the error code 11:

10ON ERROR GOTO 40

20A = 1/0

30END

40PRINT "PROGRAM ENDS IN LlNE"ERL"WITH ERROR"ERR

50RESUME NEXT RUN

PROGRAM ENDS IN LINE 20 WITH ERROR 11 Ok

ERR

The ERR function returns the code number of the last error encountered during pro- gram execution.

ERR

7-4

Page 68
Image 68
Intel 9800758-02 manual Dskf, Eof