LOC()
This page was last modified 15:25, 2 June 2020 by Mars2000you. Based on work by NYYRIKKI.

Contents

Effect

Returns

  • for a random record file: the record number that has been accessed last with GET or PUT. If no record has been accessed, number "0" will be returned.
  • for a sequential file: the number of bytes that have been read to the buffer or written from buffer to the disk. In writing mode, it will return the value 0 when you don't have yet written 256 bytes.

The file needs to be opened before using this function otherwise the "File not OPEN" error message will be displayed.

Syntax

LOC(<FileNumber>)

Parameter

<FileNumber> corresponds to the number assigned to the file when opened with the OPEN instruction. It can vary between 1 and 15, but can't exceed the maximum number of files eventually defined with MAXFILES.

Examples

10 A$="TESTFILE"
20 OPEN A$ FOR OUTPUT AS #1
30 A%=147
40 A!=123456
50 A#=12345678901234
60 PRINT#1,A$,",";A%;A!;A#
70 PRINT LOC(1)
80 B$=INKEY$
90 IF B$="" THEN 80
100 IF B$=CHR$(27) THEN 110 ELSE 60
110 CLOSE
10 OPEN "ADRESS.DAT" AS #1 LEN=66
20 FIELD #1, 15 AS NA$, 15 AS ST$, 20 AS OT$, 16 AS TE$
30 SN=LOF(1)/66
40 FOR I=1 TO SN
50 GET #1
60 PRINT "Record";LOC(1)
70 PRINT TAB(5);NA$
80 PRINT TAB(5);ST$
90 PRINT TAB(5);OT$
100 NEXT
110 PRINT "Finished"
120 CLOSE

Related to

GET, LOF(), MAXFILES, OPEN, PUT

Compatibility

Disk BASIC 1.0 or higher