LOC

Function

LOC returns the number of records read/written to a sequential file.

Syntax

LOC(file no)

Example

100 MAXFILES=2
110 OPEN "TEST" FOR INPUT AS #2
120 INPUT#2,A
130 IF EOF(2)=0 THEN GOTO 120
140 PRINT"End of File"
150 PRINT"No. of records read = ";LOC(2)
160 CLOSE#2
170 END

When the end of file has been reached the number of records that have been read will be displayed.

Remarks

The LOC function can also be used to display the number of records written to a file.

The program to create the data file TEST could be of the form:

10 OPEN "TEST" FOR OUTPUT AS#1
20 FOR X=1 TO 100
30 WRITE#1,X
40 NEXT
50 CLOSE#1
60 END

A record consists of 128 bytes, so LOC gives a measure of the amount of file space used.