DEFINITION MODULE DuDir; (* MODULE to read the directory of a current device or directory and place names/sizes into DirTable - also to Sort them in alphabetical order (case insensitive) *) FROM DOSFiles IMPORT FileLock; FROM Intuition IMPORT IntuitionText; CONST MaxMax = 300; (* Changing this allows more/less files *) (* eats mucho runtime memory 37 bytes ea *) (* 300 is enough even for my M2: dir *) TYPE DirInfo = RECORD FileName : ARRAY[0..30] OF CHAR; IsDir : BOOLEAN; IsSelected : BOOLEAN; WasSelected : BOOLEAN; FileSize : LONGCARD; END; DirPtr = POINTER TO DirInfo; VAR DirEntries : CARDINAL; FileText : IntuitionText; (* This table is full of pointers to allocated memory for storing directory entries *) DirTable : ARRAY[0..MaxMax] OF DirPtr; MaxFiles : CARDINAL; (*--------------------*) PROCEDURE ReadDirectory(lock:FileLock):BOOLEAN; (* Returns true if good read DirTable[0] contains the directory record and name. DirTable[1] - DirTable[DirEntries] contains filenames & other info *) (*------------*) PROCEDURE QSort; (* Sort the directory - DirEntries is top 1 is bottom *) (* Setup is bubble sort now - will change later *) (* Still - only 4 seconds for 230 files at that *) (*----------*) PROCEDURE MoveString(VAR tgt,src:ARRAY OF CHAR; po,le:CARDINAL); (* move max of 'le' chars of src to tgt[po] *) (* not including ending null *) PROCEDURE DisplayName(file,pos:CARDINAL); PROCEDURE DisplayFiles(ind:CARDINAL); PROCEDURE NewDir; (* Display a new directory *) PROCEDURE ClearTable; (* MUST call on exit from program to free DirTable memory used *) END DuDir.