home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1992 July / 1992-07.d64 / alphabetizer (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  1KB  |  51 lines

  1. 5 ifpeek(49152)<>160thenload"alpha.ml",8,1
  2. 15 print"[147]"tab(11)"[176][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][174]"
  3. 20 printtab(11)"[221]a - alphabetize[221]":printtab(11)"[221]d - directory  [221]"
  4. 25 printtab(11)"[221]q - quit       [221]":printtab(11)"[173][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][189]"
  5. 27 poke56,142:clr:dimfp$(144),sp$(144),ss%(144)
  6. 30 geta$:ifa$="a"then80
  7. 40 ifa$="d"thensys49411:goto680
  8. 60 ifa$<>"q"then30
  9. 70 print"[147]";:end
  10. 80 print"reading directory";:open1,8,15,"i":gosub660:close1
  11. 90 sys49152:i1=peek(7):printi1"files"
  12. 230 print"alphabetizing":fort=1toi1:sp$(t)=sp$(t)+fp$(t):next
  13. 240 n=i1:li=1:b(li)=n+1:m=1
  14. 250 j=b(li):i=m-1:ifj-m<3then360
  15. 260 mi=int((i+j)/2)
  16. 270 i=i+1:ifi=jthen320
  17. 280 ifsp$(i)<=sp$(mi)then270
  18. 290 j=j-1:ifi=jthen320
  19. 300 ifsp$(j)>=sp$(mi)then290
  20. 310 sp$=sp$(i):sp$(i)=sp$(j):sp$(j)=sp$:goto270
  21. 320 ifi>=mitheni=i-1
  22. 330 ifj=mithen350
  23. 340 sp$=sp$(i):sp$(i)=sp$(mi):sp$(mi)=sp$
  24. 350 li=li+1:b(li)=i:goto250
  25. 360 ifj-m<2then390
  26. 370 ifsp$(m)<sp$(m+1)then390
  27. 380 sp$=sp$(m):sp$(m)=sp$(m+1):sp$(m+1)=sp$
  28. 390 m=b(li)+1:li=li-1:ifli>0then250
  29. 400 fort=1toi1:fp$(t)=right$(sp$(t),5):sp$(t)=left$(sp$(t),27):next
  30. 410 open1,8,15,"i":gosub660:open8,8,8,"#":i2=1:print"writing directory"
  31. 420 print#1,"b-p";8;0
  32. 430 c=0:reads:ifi1-i2<8thenprint#8,chr$(0)chr$(255);:goto450
  33. 440 print#8,chr$(18)chr$(s);
  34. 450 print#8,right$(fp$(i2),3);:goto470
  35. 460 print#8,fp$(i2);
  36. 470 print#8,sp$(i2);
  37. 480 ifi2=i1then510
  38. 490 i2=i2+1:c=c+1:ifc<8then460
  39. 500 reads:print#1,"u2";8;0;18;s:goto420
  40. 510 a$="":fort=1to32:a$=a$+chr$(0):next
  41. 520 c=c+1:ifc=8then540
  42. 530 print#8,a$;:goto520
  43. 540 reads:print#1,"u2";8;0;18;s:close8:sys49411:goto680
  44. 550 data 4,1,7,4,10,7,13,10,16,13,2,16,5,2,8,5,11,8,14,11,17,14,3,17,6,3,9,6
  45. 560 data 12,9,15,12,18,15,0,18
  46. 660 input#1,a,b$,c,d:ifa=0thenreturn
  47. 670 printa;b$;c;d
  48. 680 close1:print"press return"
  49. 690 geta$:ifa$<>chr$(13)then690
  50. 700 run
  51.