Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site gatech.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!ihnp4!zehntel!dual!amd!decwrl!decvax!ittvax!dcdwest!sdcsvax!akgua!gatech!strick From: strick@gatech.UUCP Newsgroups: net.micro.6809 Subject: OS9 directory sorter -- basic09 source Message-ID: <9604@gatech.UUCP> Date: Mon, 13-Aug-84 14:27:28 EDT Article-I.D.: gatech.9604 Posted: Mon Aug 13 14:27:28 1984 Date-Received: Thu, 16-Aug-84 03:21:53 EDT References: <9595@gatech.UUCP> Organization: The Clouds Project, School of ICS, Georgia Tech Lines: 69 Here's a quick basic09 program to sort the files in a directory by name. Makes dirs more readable. Try it first on a disk with NOTHING important on it, because if either you or I make a mistake typing this in, it'll fry the directory. The program is not very efficient (uses StupidSort) but it does the job. It takes approx 40 seconds to sort 40 filenames. Empty slots are sorted to the bottom so new files added to the directory will show up at the bottom of the dir. strick ========================= PROCEDURE sortdir comments: TYPE dent = e(32) : BYTE dir entries are 32 bytes DIM d(100), t : dent up to 100 entries DIM p : BYTE DIM i : INTEGER PRINT "DIRECTORY SORTER" INPUT "Directory to sort > ", path$ OPEN #p, path$ : UPDATE + DIR PRINT "Directory open." I = 1 WHILE NOT( EOF(#p) ) DO GET #p, d(i) read in the dir file i = i + 1 ENDWHILE numrec = i - 1 PRINT numrec; " records" FOR d1=3 to numrec-1 very stupid bubble sort FOR d2=3 to numrec-1 x=d2 \ y=d2+1 x & y are inputs to sub500 GOSUB 500 compares entries IF z=1 THEN z is output from sub500 t=d(x) \ d(x)=d(y) \ d(y)=t swap entries ENDIF NEXT d2 print "."; NEXT d1 SEEK #p,0 rewind directory FOR i=1 to numrec PUT #p,d(i) write sorted dir out NEXT i CLOSE #p PRINT "done." END 500 REM comparison subroutine a dir entry is 29 bytes of name REM input x,y indexes to compare and 3 bytes of i-node. We will REM output z= if d(x)127 THEN a=a-128 \ ENDIF IF b>127 THEN b=b-128 \ ENDIF EXITIF ab THEN z=1 \ ENDEXIT wrong order -- must swap NEXT i RETURN ================================ -- Henry Strickland The Clouds Project, School of ICS, Georgia Tech, Atlanta GA 30332 CSNet: Strick @ GATech ARPA: Strick.GATech @ CSNet-Relay uucp: ...!{akgua,allegra,rlgvax,sb1,unmvax,ulysses,ut-sally}!gatech!strick