home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / club100 / txt / hdsort.ba < prev    next >
Text File  |  2006-10-19  |  1KB  |  26 lines

  1. 0 'CLUB 100 Library - 415/939-1246 BBS,    937-5039 NEWSLETTER, 932-8856 VOICE
  2. 1 'HDSORT.BA - by Phil Wheeler
  3. 2 CLS:CLEAR2000:FILES:A$="Which file to sort: ":GOSUB14:INPUTF$:IFMID$(F$,LEN(F$)-2,1)<>"."THENF$=F$+".DO"
  4. 3 A$="Lines in Header ":GOSUB14:INPUTM: OPENF$FORINPUTAS1:FORJ=1TOM+1:LINEINPUT#1,Z$:EXT
  5. 4 CLS:PRINT"----.----1----.----2----.----3----.----4";:PRINTZ$
  6. 5 A$="Begin at position: ":GOSUB14:INPUTB:IFB=0THEN5
  7. 6 A$="End at position: ":GOSUB14:INPUTE:N=M+1:CLS:PRINT@170,"Sorting...."
  8. 7 N=N+1:LINEINPUT#1,Z$:IFEOF(1)THENGOTO9
  9. 8 GOTO7
  10. 9 CLOSE:DIMD$(N):DIMY$(M):OPENF$FORINPUTAS1:IFM=0THENGOTO11
  11. 10 FORJ=1TOM:LINEINPUT#1,Y$(J):NEXT
  12. 11 FORI=M+1TON:LINEINPUT#1,D$(I):NEXT:CLOSE1:GOSUB15:KILLF$:OPENF$FOROUTPUTAS1:IFM=0THENGOTO13
  13. 12 FORJ=1TOM:PRINT#1,Y$(J):NEXT
  14. 13 FORI=M+1TON:PRINT#1,D$(I):NEXTI:CLOSE:MENU
  15. 14 PRINT@240,STRING$(40,32);:PRINT@240,A$;:RETURN
  16. 15 Z5=N
  17. 16 Z5=INT(Z5/2):IFZ5=0THEN24
  18. 17 Z2=1:Z3=N-Z5
  19. 18 Z1=Z2
  20. 19 Z4=Z1+Z5:IF(MID$(D$(Z1),B,(E-B)+1))<(MID$(D$(Z4),B,(E-B)+1))THEN22ELSE20
  21. 20 Z6$=D$(Z1):D$(Z1)=D$(Z4):D$(Z4)=Z6$:Z1=Z1-Z5:IFZ1<1THEN22
  22. 21 GOTO19
  23. 22 Z2=Z2+1:IFZ2>Z3THEN16
  24. 23 GOTO18
  25. 24 RETURN
  26.