A batch for displaying the System File Table

This is a neat batch which displays the computer's table of file handles. I can't get too technical because to be honest I know little of what goes on down there, but detailed knowledge is not required to simply display it. I only needed to find the table's starting point in memory (and so will you if you try to get this batch to work), the offsets and step of the filenames, and where the open-file flag is. I gathered this info using tools like MSD and DEBUG. The files are displayed in columns, * is placed after the files which are currently open.

The batch echoes out a QBasic program, runs it then deletes it. The trick to echoing QBasic code is doing without < and >, ouch. No matter, SGN(a-32)=1 is functionally equivalent to a>32. You must customize the numbers after memstart= and numfiles= or it won't work properly if at all. Follow the instructions listed in the comments for to find the start of the system file table using the MSD utility, the value for numfiles can be found in the CONFIG.SYS file.

:: SFT.BAT - (c) 1996 Terry Newton
:: Displays the System File Table
:: QBasic.exe must be on the path!
:: Open files are marked by * after filename (usually)
:: NOTE!! The constants for memstart and numfiles depend on computer!
:: Before running you should use MSD or equivalent to get numbers.
:: Note--ProView shows addresses 16 bytes lower, pv=03680 msd=0369(0)
:: Run Dos's MSD, select TSR and get address of File Handles
:: (mine reads 0369 hex) add a 0 to make 03690 = 13968 decimal
:: add 38 to result to get 14006 (that used to be) used below.
:: The numfiles setting should match the FILES= setting in CONFIG.SYS
:: If major system change or it prints garbage, recalculate numbers
@echo off
echo> sft$.bas memstart=14102:numfiles=50
echo>>sft$.bas CLS:DEF SEG=0:r=2:c=2:memend=memstart+numfiles*59-1
echo>>sft$.bas FOR i=memstart TO memend STEP 59
echo>>sft$.bas LOCATE r,c:FOR j=i TO i+10
echo>>sft$.bas a=PEEK(j):IF SGN(a-31)=1 AND SGN(128-a)=1 THEN PRINT CHR$(a);
echo>>sft$.bas NEXT j:IF SGN(PEEK(i-32))=1 THEN PRINT "*";
echo>>sft$.bas r=r+1:IF SGN(r-24)=1 THEN r=2:c=c+14
echo>>sft$.bas NEXT i:LOCATE 22,1:SYSTEM
qbasic.exe /run sft$.bas
del sft$.bas