1170 IF NB = 0 AND PK = 0 THEN NUM = NN: GOSUB 250: POKE 824,LB: POKE 825,HB
1180 IF NB = 1 THEN NUM = NN: GOSUB 250: POKE 820 +(PK +1) *4,LB: POKE 821 +(PK +1) *4,HB
1190 IF PK >0 THEN 1210
1200 NUM = MEM +1: GOSUB 250:D1 = LB:D2 = HB
1210 CN = SB: GOSUB 140
1220 FOR I = 1 TO 50: IF SB = SB(I) THEN 1240
1230 NEXT I
1240 IF SB(I +1) >0 THEN NSB = SB(I +1) -1
1250 IF SB(I +1) = 0 THEN NSB = SB +200
1260 FOR I = SB TO NSB
1270 GOSUB 1280:ADR = NXADR: GOTO 1270
1280 NXADR = PEEK(ADR) + PEEK(ADR +1) *256
1290 LN = PEEK(ADR +2) + PEEK(ADR +3) *256
1300 IF LN < >I THEN POP : NEXT I: GOTO 1390
1310 NUM = ADR: GOSUB 250:S1 = LB:S2 = HB
1320 NUM = NXADR -1: GOSUB 250:E1 = LB:E2 = HB
1330 GOSUB 410: REM MOVE MEMORY
1340 X = D1 +D2 *256:Y = NXADR -ADR
1350 NUM = X +Y: GOSUB 250: POKE X,LB: POKE X +1,HB
1360 D1 = LB:D2 = HB
1370 NUM = NN: GOSUB 250: POKE X +2,LB: POKE X +3,HB
1380 NN = NN +LI: RETURN
1390 PK = PK +1: IF NB = 0 THEN NUM = NN -LI: GOSUB 250: POKE 826,LB: POKE 827,HB
1400 IF NB = 1 THEN NUM = NN -LI: GOSUB 250: POKE 820,PK: POKE 822 +PK *4,LB: POKE 823 +PK *4,HB
1410 IF NB = 0 THEN NN = INT(NN/LS) *LS +LS
1420 TEXT : HOME : GOTO 870
1430 TEXT : HOME : VTAB 4: PRINT "SORRY - YOU'VE PICKED ONE MORE SUB-": PRINT
1440 PRINT "ROUTINE THAN WILL FIT IN MEMORY.": PRINT : PRINT
1450 PRINT "WHEN YOU CONTINUE, ALL SUBROUTINES UP": PRINT
1460 PRINT "TO ";SB;" WILL BE ADDED TO THE PROGRAM": PRINT : PRINT "YOU CHOOSE.": PRINT
1470 PRINT : PRINT "YOU'LL HAVE TO RUN SUBROUTINE STORE": PRINT
1480 PRINT "AGAIN TO ADD THIS ONE (AND OTHERS).": GOSUB 220: GOTO 15270
1490 REM CHECK FOR SUBROUTINE TO SAVE
1500 IF PEEK(MEM +1) + PEEK(MEM +2) = 0 THEN TEXT : HOME : GOTO 15050
1510 GOTO 15270
1520 TEXT : HOME : POKE 115, PEEK(780): POKE 116, PEEK(781): POKE 782,0: END
5000 REM ANY KEY TO CONTINUE ROUTINE
5010 VTAB 23: PRINT "PRESS ANY KEY TO CONTINUE. ";: GET X$
5020 RETURN
15000 TEXT : HOME : HTAB 11: INVERSE : PRINT "SUBROUTINE STORAGE": PRINT : PRINT
15010 NORMAL : PRINT "THIS PROGRAM PROVIDES A PLACE TO STORE": PRINT : PRINT "SUBROUTINES TO MERGE LATER WITH AN": PRINT
15020 PRINT "APPLESOFT PROGRAM YOU'RE DEVELOPING.": PRINT : PRINT : PRINT "THE SUBROUTINES BEGIN AT LINE 5000 AND": PRINT
15030 PRINT "AT EVEN INCREMENTS OF 100 AFTER THAT.": PRINT : PRINT
15040 PRINT "THIS PROGRAM SHOULD BE ON THE SAME DISK": PRINT : PRINT "WITH YOUR APPLESOFT PROGRAM.": PRINT : PRINT "* COPYRIGHT 1985 MICROSPARC, INC. *": GOSUB 220
15080 PRINT " PICK ONE OR MORE TO MERGE WITH": PRINT
15090 PRINT " AN EXISTING APPLESOFT PROGRAM.": PRINT : PRINT
15100 PRINT " 2 - ADD A NEW SUBROUTINE(S).": PRINT : PRINT " 3 - QUIT.": PRINT
15110 GET X$:X = VAL(X$): IF X <1 OR X >3 THEN HOME : GOTO 15050
15120 ON X GOTO 820,15130,1520
15130 HOME : VTAB 12: HTAB 13: INVERSE : PRINT "PLEASE STAND BY": NORMAL : GOSUB 270: REM FIND SUBROUTINE LINE NUMBERS
15140 IF SB(1) = 0 THEN HOME : VTAB 8: PRINT "SINCE THIS PROGRAM CONTAINS NO": PRINT : PRINT "SUBROUTINE AT LINE 5000, BEGIN": PRINT : PRINT "THE FIRST ONE AT LINE 5000."
15150 POKE 115, PEEK(780): POKE 116, PEEK(781): POKE 782,0: REM CHANGE HIMEM BACK
15160 IF SB(1) = 0 THEN END
15170 FOR I = 1 TO 50: IF SB(I) = 0 THEN 15190
15180 NEXT
15190 HOME : VTAB 4: PRINT "THE LAST SUBROUTINE STORED IN THIS": PRINT
15200 PRINT "PROGRAM ENDS BEFORE ";CN: PRINT
15210 PRINT "BEGIN THE NEXT ONE AT ";CN
15220 PRINT : PRINT
15230 PRINT "YOU HAVE ";I -1;" SUBROUTINES STORED IN": PRINT
15240 PRINT "THIS PROGRAM AND ROOM FOR ";51 -I;" MORE."
15250 POKE 115, PEEK(780): POKE 116, PEEK(781): POKE 782,0: REM CHANGE HIMEM BACK
15260 END
15270 D$ = CHR$(13) + CHR$(4): REM RETURN + CONTROL D
15280 TEXT : HOME
15290 PRINT D$;"MON C,I,O"
15300 TEXT : HOME : VTAB 4: PRINT "PLEASE ENTER THE NAME OF THE APPLESOFT": PRINT