2000 REM ...... THIS IS FILE "RESEQ2.BAS"
2010 
2020 !----------------------------------------------------!
2030 !  PROGRAM TO RESEQUENCE ALPHABASIC SOURCE PROGRAMS  !
2035 !  BY MANUAL STEP-THROUGH     (ASSUMES LABELS USED)  !
2040 !----------------------------------------------------!
2050 
2060 REM ...... STRING DEFINTIONS
2070   MAP1 TEXT$  ,S,100
2080   MAP1 COMD$  ,S,1
2090   MAP1 SLINE$ ,S,10
2100   MAP1 CHAR$  ,S,1
2120   MAP1 SHARP$ ,S,1,"#"
2130   MAP1 NLINE$,S,10
2140   MAP1 FNAME1$,S,15
2150   MAP1 FNAME2$,S,15
2160 
2170 NEW'FILE:
2180   PRINT TAB(-1,0);
2190   PRINT "ENTER INPUT (CURRENT) FILE NAME : <          >";
2200   FOR I=1 TO 11  :  PRINT CHR(8);  :  NEXT I
2210   INPUT "" FNAME1$
2220   PRINT "ENTER OUTPUT (NEW) FILE NAME    : <          >";
2230   FOR I=1 TO 11  :  PRINT CHR(8);  :  NEXT I
2240   INPUT "" FNAME2$
2250 
2260 REM ...... OPEN FILES
2270   LOOKUP FNAME1$, THERE
2280   IF(THERE=0) THEN PRINT "ERROR---INPUT FILE NOT FOUND" : GO TO END
2290   OPEN #1, FNAME1$, INPUT
2300   LOOKUP FNAME2$, THERE
2310   IF(THERE <> 0) THEN ? "ERROR---OUTPUT FILE EXISTS !" : GO TO END
2320   OPEN #2, FNAME2$, OUTPUT
2330 
2340 REM ...... SET INITIAL CONDITIONS
2350   XLINE=0
2360   INCR=10
2370   PRINT
2380   PRINT
2390 
2400 
2410 
2420 NEXT'LINE:
2430   INPUT LINE #1, TEXT$
2440   IF(EOF(1)=1) THEN GO TO END'OF'FILE
2450   SLINE$=""
2460 
2470 NEXT'DIGIT:
2480   CHAR$=LEFT$(TEXT$,1)
2490   IF(CHAR$ < "0" OR CHAR$ > "9") THEN GO TO INPUT'LINE'NUMBER
2500   SLINE$=SLINE$+CHAR$
2510   L=LEN(TEXT$)
2520   TEXT$=RIGHT$(TEXT$,L-1)
2530   GO TO NEXT'DIGIT
2540 
2550 INPUT'LINE'NUMBER:
2560   PRINT SLINE$+TEXT$
2570   PRINT
2580   YLINE=XLINE+INCR
2590   PRINT USING "NEW ! : <#####>", SHARP$, YLINE;
2600   FOR I=1 TO 6  :  PRINT CHR(8);  :  NEXT I
2610   INPUT "" YLINE
2620   IF(YLINE > XLINE) THEN GO TO RESEQUENCE
2630   PRINT "ERROR---LINE #"; YLINE; "OUT OF SEQUENCE"
2640   PRINT TAB(-1,3); TAB(-1,3); TAB(-1,3); TAB(-1,3);
2650   GO TO INPUT'LINE'NUMBER
2660 
2670 RESEQUENCE:
2680   INCR=YLINE-XLINE
2690   XLINE=YLINE
2700 
2710 REM ...... WRITE RE-NUMBERED LINE TO OUTPUT FILE
2720   NLINE$=STR$(XLINE)
2730   PRINT #2, NLINE$+TEXT$
2740 
2750 REM ...... UPDATE SCREEN
2760   PRINT TAB(-1,3); TAB(-1,3); TAB(-1,3); NLINE$;
2770   IF(LEN(NLINE$) <> LEN(SLINE$)) THEN PRINT TAB(-1,9); TEXT$;
2780   PRINT
2790   PRINT TAB(-1,10);
2800   GO TO NEXT'LINE
2810 
2820 
2830 
2840 
2850 END'OF'FILE:
2860   CLOSE #1
2870   CLOSE #2
2880   PRINT
2890   PRINT "[END OF SOURCE TEXT]"
2900   PRINT
2910 
2920 REM ...... AGAIN ?
2930   COMD$="N"
2940   INPUT "DO YOU WANT TO RENUMBER ANOTHER FILE ('Y' OR 'N') : ", COMD$
2950   IF(COMD$="Y") THEN GO TO NEW'FILE
2960 
2970 END:
2980   END