home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nibble Magazine
/
nib35a.dsk
/
DECEMBER.1988
/
MERGESORT.bas
< prev
next >
Wrap
BASIC Source File
|
2023-02-26
|
4KB
|
89 lines
10 REM *
20 REM * MERGESORT
30 REM * BY CHESTER H. PAGE
40 REM * COPYRIGHT (C) 1988
50 REM * BY MICROSPARC, INC.
60 REM * CONCORD, MA 01742
70 REM *
80 ONERR GOTO 890
90 LOMEM: 33280: HIMEM: 35328
100 PRINT CHR$(4);"BLOAD MERGESORT.OBJ"
110 POKE 216,0: POKE 26,154
120 HOME : HTAB 5: VTAB 4: PRINT "MERGESORT": PRINT : HTAB 5: PRINT "BY CHESTER H. PAGE": HTAB 5: PRINT "(C) 1988 MICROSPARC, INC.": PRINT
130 PRINT " 1) SHOW LIST IN PRESENT ORDER"
140 PRINT " 2) REORDER LIST ON LINE L"
150 PRINT " 3) PRINT LIST IN PRESENT ORDER"
160 PRINT " 4) SAVE LIST TO DISK"
170 PRINT " 5) LOAD NEW FILE"
180 PRINT " 6) CATALOG"
190 PRINT " 7) CHANGE SLOT & DRIVE"
200 PRINT " 8) QUIT"
210 VTAB 18: PRINT "YOUR CHOICE:";: POKE -16368,0: GET AN$: PRINT
220 IF AN$ <"1" OR AN$ >"8" THEN 210
230 X = VAL(AN$)
240 IF X <5 AND PEEK(26) = 154 THEN PRINT : PRINT "NO TEXT FILE IN MEMORY": GOSUB 530: GOTO 120
250 ON X GOTO 270,290,350,370,570,550,780,770
260 REM * PRINT LIST
270 HOME : POKE 249,0: CALL 4617: GOSUB 530: GOTO 120
280 REM * REORDER LIST
290 HOME : INPUT "LINE NUMBER ";L
300 IF L <1 OR L >5 THEN GOTO 290
310 POKE 239,L
320 HOME : VTAB 10: PRINT "REORDERING "F$: CALL 4614
330 PRINT : PRINT F$" REORDERED ON LINE "L: GOSUB 530: GOTO 120
340 REM * PRINT LIST TO PRINTER
350 HOME : PRINT "PRINTING": PRINT D$"PR#1": POKE 249,0: CALL 4617: PRINT D$"PR#0": GOSUB 530: GOTO 120
360 REM * SAVE LISTING
370 HOME : HIMEM: 36352:D$ = CHR$(4): ONERR GOTO 420
380 INPUT "SAVE AS FILE NAMED: ";F$
390 IF F$ = "" THEN GOTO 120
400 PRINT D$;"VERIFY "F$
410 GOTO 490
420 ONERR GOTO 510
430 PRINT D$"OPEN"F$
440 PRINT D$"WRITE"F$
450 POKE 249,1: CALL 4617
460 PRINT D$"CLOSE": HIMEM: 35328
470 HOME : PRINT "FILE SAVED: "F$: GOSUB 530: POKE 216,0: GOTO 120
480 REM * ERROR TRAP
490 POKE 216,0: PRINT : PRINT "FILE ALREADY EXISTS. OVERWRITE (Y/N):";: POKE -16368,0: GET AN$: IF AN$ = "N" OR AN$ = "n" THEN GOTO 120
500 GOTO 420
510 POKE 216,0: POKE 26,154: PRINT : PRINT "ILLEGAL FILE NAME OR FILE NOT FOUND": GOSUB 530: GOTO 120
520 PRINT D$"CLOSE": PRINT "FILE TOO LARGE": GOSUB 530: GOTO 120
530 PRINT : PRINT "PRESS RETURN TO CONTINUE.";: POKE -16368,0: GET AN$: RETURN
540 REM * CATALOG
550 HOME : VTAB 1: PRINT CHR$(4);"CAT": GOSUB 530: GOTO 120
560 REM * LOAD NEW LISTING
570 HOME : HIMEM: 35328: ONERR GOTO 510
580 D$ = CHR$(4)
590 INPUT "LOAD FILE NAMED: ";F$
600 IF F$ = "" THEN GOTO 120
610 POKE 26,0
620 PRINT D$;"VERIFY ";F$
630 PRINT D$;"OPEN ";F$
640 POKE 216,0
650 CALL 4608
660 PRINT D$"CLOSE"
670 IF PEEK(771) < >0 THEN 690
680 PRINT : PRINT "EMPTY FILE": GOSUB 530: GOTO 120
690 ONERR GOTO 760
700 PRINT D$;"BLOAD ";F$;",A$1600,TTXT"
710 T = (( PEEK(01) *256) + PEEK(0)) -1: IF T >33279 THEN PRINT : PRINT "FILE TOO LARGE.": GOSUB 530: POKE 26,154: GOTO 120
720 IF PEEK(T) < > PEEK(5632) AND PEEK(T -1) < > PEEK(5632) THEN PRINT : PRINT "INCORRECT TEXT FILE FORMAT": GOSUB 530: POKE 26,154: GOTO 120
730 POKE 216,0: CALL 4611
740 IF PEEK(26) = 154 THEN PRINT : PRINT "MORE THAN 510 ITEMS IN LIST": GOSUB 530: GOTO 120
750 GOTO 120
760 PRINT : PRINT "FILE TOO LARGE": POKE 26,154: POKE 216,0: GOSUB 530: GOTO 120
770 HOME : VTAB 23: END
780 HOME : VTAB 1: PRINT "SLOT:";: POKE -16368,0: GET S$: PRINT S$
790 IF S$ = CHR$(13) THEN GOTO 120
800 IF S$ <"1" OR S$ >"7" THEN GOTO 780
810 VTAB 2: PRINT "DRIVE:";: POKE -16368,0: GET DR$: PRINT DR$
820 IF DR$ = CHR$(13) THEN GOTO 120
830 IF DR$ <"1" OR DR$ >"2" THEN GOTO 810
840 ONERR GOTO 870
850 PRINT CHR$(4);"PREFIX,S";S$;",D";DR$
860 POKE 216,0: GOTO 120
870 POKE 216,0: PRINT : PRINT "INVALID SLOT AND DRIVE.": GOSUB 530
880 GOTO 780
890 POKE 216,0: HOME : PRINT "CANNOT FIND FILE:MERGESORT.OBJ"