FILE_LEN (filename) or

FILE_LEN (file$)

Location TinyToolkit

This function returns the length of a file in bytes. It does not support the default devices or sub-directories.


A short program to show simple file statistics (without any support of wild cards):

100 dev$="FLP1_"
110 OPEN#3,PIPE_10000: OPEN#4,PIPE_200
120 TCONNECT #3 TO #4
130 DIR#3,dev$: INPUT#4,h$\h$
140 :
150 sum=0: count=0
160 REPeat add_lengths
170   IF NOT PEND(#4) THEN EXIT add_lengths
180   INPUT#4,file$
185   IF " ->" INSTR file$ THEN NEXT add_lengths
190   sum=sum+FILE_LEN(dev$ & file$)
200   count=count+1
210 END REPeat add_lengths
220 :
230 CLS
240 PRINT "There are"!count!"files in"!dev$;"."
250 PRINT "They are altogether"!sum!"bytes long,"
260 PRINT "the average length is"!INT(sum/count+.5)!"bytes."

TinyToolkit’s TCONNECT or DIY Toolkit’s QLINK is necessary


It is not recommended to get a file list by writing a directory into a file or pipe. Problems arise with sub-directories on level-2 drivers: a sub-directory is marked with an appended ” ->” in the directory list (WDIR, WSTAT, DIR), so opening a file such a “test ->” will fail. Refer to OPEN_DIR and FOP_DIR for a cleaner method.


FLEN has a more flexible syntax. FILE_TYPE, FILE_DAT, FILE_POS, FNAME$, FPOS, FTYP, FUPDT and FXTRA hold other information on a file.