
LOC is a function that serves three purposes. The key purpose is to determine the position of the file pointer of an open file. In this case, LOC must be called with the handle number of that file. The file must be open for reading or writing. To query the number of used Kbytes on disk, LOC must be called with 0 as argument. Whether LOC was called with 0 or a handle number, if there's no disk inserted, LOC returns 0 and LASTERR is set so 9 (ERR_NO_DISK).
This example prints the number of used Kbytes on disk:
outmode -2 let a = loc(0)
let e = LASTERR
if e = 0 then
print "used space: ";
print a
else
print "error: ";
print e
end if
Since the Scripting Language works with 32 bit signed integers, which maximum positive value is 2,147,483,647, LOC might return negative or wrong values on files bigger than that. See also the LOF page