! NUMBER.BAS  - Of unknown origin and vastly rewritten by mds and ske
! at various times
! last update 4/5/83 ske - some screen formatting and better prompts for
! lines & increments

MAP1 A,S,132
MAP1 B,S,24
MAP1 C,S,5
map1 dummy,s,1

INTRO:
       ? tab(-1,0)
       ? tab(2,30); "Line Numbering Program"
       ? tab(3,1);
       for n = 1 to 78
           ? "=";
       next n

       ? tab(10,10);
       input "Do you need instructions? ", dummy
       if ucs(dummy) = "Y" then gosub INSTRUCTIONS
       ? tab(10,1); tab(-1,10);

ENTER'FILE'NAME:
       ? tab(23,10); "The default extension is .BAS"
       ? tab(10,10);
       input "Enter the name of the file to be numbered -->  ",B
       B = ucs(B)
       D=instr(1,B,".")
       if D=0 then B=B+".BAS"
       open #1,B,input
       ? tab(5,10); "Original file: "; B
       D=instr(1,B,".")
       B=B[1;D-1] :B=B+".NEW"
       ? tab(5,42); "Destination file: "; B
       ? tab(10,10); tab(-1,10);
       input "What number would you like the program to start with --> ", START
       ? tab(12,10);
       input "What increment would you like? (5, 10, 100, etc.) --> ", INC
       open #2,B,output
       ? tab(10,1); tab(-1,10); "processing";

START:
       input line #1,A
       ? ".";
       if eof(1)=1 then goto FINISHED
       if CFLAG &
           then &
               ? #2,A :&
                goto CONT'LINE
       X = A
       if X = 0 goto SKIP
       X = len(STR(X))
       A = A[X+1,-1]

SKIP:
       C = str(START)
       START = START+INC
       A = C+" "+A
       ? #2,A

CONT'LINE:
       if A[-1,-1]="&" &
           then &
               CFLAG=-1 &
           else &
               CFLAG=0
       goto START

FINISHED:
       close #1
       close #2
       ? tab(10,1); tab(-1,10);
       ? tab(23,1); "done";CHR(7)
       end
! ###################################################################

INSTRUCTIONS:
       ? tab(10,1); tab(-1,10);
       ? "This program will put numbers at the beginning of BASIC"
       ? "programs that you have created using VUE or EDIT that have no"
       ? "line numbers already on them.  This program will create a new"
       ? "file with the extension .NEW for the program with the line numbers."
       ? "You will be asked the name of your file, and you can enter the"
       ? "beginning line number, and the increment you wish. "
       ?
       input "hit RETURN to begin ", dummy
       return