10  PRINT CHR$(26):REM "CRITICAL PATH ANALYSIS"
20  PRINT "CRITICAL PATH METHOD NORMAL AND CRASH TIME/COST"
50  PRINT:PRINT "*** NOTE BEGINNING EVENTS WILL BE SORTED NUMERICAL ORDER ***"
55  INPUT "DIMENSION FOR ACTIVITIES";D%:PRINT
60  DIM A$(D%,2),A(D%,13),SV(12)
70  PRINT :PRINT: PRINT "INPUT MENU": PRINT: PRINT
80  PRINT "      K    KEYBOARD"
90  PRINT "      D    DISK FILE"
100 PRINT "      R    READ STATEMENT"
110 PRINT: PRINT
130 INPUT "SELECTION";IO$
140 IF IO$ <> "K" THEN 330
150 INPUT "NUMBER OF ACTIVITIES";M%:EE=0
160 PRINT "IF THIS IS GOING TO BE WORK YOU MUST NOW INPUT UP TO ";M%;" ACTIVITIES"
170 FOR I = 1 TO M%
180 INPUT "ACTIVITY CODE ";A$(I,1)
190 INPUT "DESCRIPTION, BEGINNING EVENT NO., END EVENT NO., NORMAL TIME & COST, AND CRASH TIME & COST";A$(I,2),A(I,1),A(I,2),A(I,3),A(I,4),A(I,5),A(I,6)
200 NEXT I
210 GOTO 480
330 IF IO$ <> "D" THEN 420
340 INPUT "NAME OF FILE:DISK ";B$:REM DISK INPUT
350 OPEN "I",1,B$
360 INPUT #1,M%,EE
370 FOR I = 1 TO M%
380 INPUT #1,A$(I,1),A$(I,2),A(I,1),A(I,2),A(I,3),A(I,4),A(I,5),A(I,6)
390 NEXT I
400 CLOSE 1
410 GOTO 480
420 IF IO$ <> "R" THEN PRINT CHR$(7);CHR$(26);: GOTO 70
430 READ M%,EE
440 FOR I = 1 TO M%:REM READ INPUT
450 READ A$(I,1),A$(I,2),A(I,1),A(I,2),A(I,3),A(I,4),A(I,5),A(I,6)
460 IF A$(I,1) = "END" THEN 480
470 NEXT I
480 REM PRINT INPUT DATA FOR VERIFICATION
490 M=M%:TP=0:FOR I = 1 TO M:IF A(I,2) > TP THEN TP = A(I,2)
495 NEXT : EE=TP
500 FOR I = 1 TO M-1
510 FOR J = I + 1 TO M
520 IF A(I,1)<=A(J,1) THEN 550
530 FOR K = 1 TO 12:SV(K)=A(I,K):A(I,K)=A(J,K):A(J,K)=SV(K):NEXT K
540 FOR K = 1 TO 2:SV$(K)=A$(I,K):A$(I,K)=A$(J,K):A$(J,K)=SV$(K):NEXT K 
550 NEXT J,I
560 XX=5:PRINT"VERIFICATION OF INPUT"
570 Z1$="CODE DESCRIPTION TIME     EARLY     EARLY     LAST     LAST     SLACK"
580 Z2$="                 USED     START     FIN       START    FIN      TIME"  
590 Z3$="CODE DESCRIPTION BEGIN  END        NORMAL          CRASH"
600 Z4$="                EVENT  EVENT    TIME    COST    TIME    COST"
610 PRINT "NO ";Z3$
620 PRINT "   ";Z4$
625 PRINT
630 K=0
640 C4$="### "
650 FOR I = 1 TO M%
660 PRINT USING C4$;I;
670 C1$=" #### "
680 C2$="\ \ \         \":C3$=" ####.##"
690 PRINT USING C2$;A$(I,1),A$(I,2);
700 FOR J = 1 TO 2
710 PRINT USING C1$;A(I,J);:NEXT J
720 FOR J = 3 TO 6
730 PRINT USING C3$;A(I,J);:NEXT J
740 K=K+1:IF K >= 13 THEN PRINT:INPUT "ENTER TO PAGE";DU$:K=0
750 PRINT:NEXT I
760 INPUT "-2 TO ADD, -1 TO CONTINUE OR NUMBER TO CHANGE";L:IF L =-1 THEN 810
770 IF L <>-2 THEN 790
780 L=M%+1:M%=L:N%=N%+1
790 INPUT "INPUT CODE, DESCRIPTION, BEGINNING EVENT NUMBER, END EVENT NUMBER,NORMAL TIME, COST AND CRASH TIME AND COST";A$(L,1),A$(L,2),A(L,1),A(L,2),A(L,3),A(L,4),A(L,5),A(L,6)
800 GOTO 480
810 INPUT "HARD COPY OF INPUT DATA (Y/N)";P$
820 IF P$<>"Y" THEN 960
830 INPUT "TITLE";T$:LPRINT "TITLE: ";T$
840 INPUT "DATE";T$:LPRINT "DATE: ";T$
850 LPRINT "NO ";Z3$
860 LPRINT "   ";Z4$
870 FOR I = 1 TO M%
880 LPRINT USING C4$;I;
890 LPRINT USING C2$;A$(I,1),A$(I,2);
900 FOR J=1 TO 2
910 LPRINT USING C1$;A(I,J);:NEXT J
920 FOR J=3 TO 6
930 LPRINT USING C3$;A(I,J);:NEXT J
940 LPRINT " "
950 NEXT I
960 REM NOW THE WORK BEGINS BEGINNING EVENT IS 1 EARLY START = 0 FORWARD PASS
970 INPUT "NORMAL TIME OR FULL CRASH TIME (N/C)";NC$:IF NC$<>"N" AND NC$<>"C" THEN 970
980 FOR I =1 TO M%:IF NC$="N" THEN A(I,7)=A(I,3)
990 IF NC$="C" THEN A(I,7) = A(I,5)
1000 NEXT I
1010 FOR I = 1 TO M%
1020 IF A(I,1)=1 THEN A(I,8)=0:A(I,9)=A(I,7):GOTO 1100
1030 MAX=0!
1040 FOR J=1 TO M%
1050 IF A(J,2)<>A(I,1) THEN 1080
1060 IF A(J,9) >MAX THEN MAX=A(J,9)
1070 A(I,8) = MAX
1080 NEXT J
1090 A(I,9)=A(I,8)+A(I,7)
1100 NEXT I
1110 REM BACKWARD PASS
1120 XM=0! 
1130 FOR I=M% TO 1 STEP -1
1140 IF A(I,2)<>EE THEN 1160
1150 IF XM<A(I,9) THEN XM=A(I,9)
1160 NEXT I  
1170 FOR I=M% TO 1 STEP -1 
1180 IF A(I,2) = EE THEN A(I,11)=XM:GOTO 1250
1190 MIM=99999!
1200 FOR J=M% TO 1 STEP -1
1210 IF A(I,2) <> A(J,1) THEN 1240
1220 IF A(J,10) < MIM THEN MIM =A(J,10)
1230 A(I,11) = MIM
1240 NEXT J
1250 A(I,10) = A(I,11)-A(I,7)
1260 NEXT I
1270 REM SLACK VARIABLE CALCULATIONS
1280 FOR I=1 TO M%
1290 A(I,12)=A(I,11) - A(I,9)
1300 NEXT I
1310 K=0:REM PRINT OUTPUT
1320 PRINT "CODE DESCRIPTION TIME     EARLY     EARLY     LAST     LAST     SLACK"
1330 PRINT "                 USED     START     FIN       START    FIN      TIME"  
1340 C5$=" #####.##"
1350 FOR I = 1 TO M%
1360 PRINT USING C2$;A$(I,1),A$(I,2);
1370 FOR J=7 TO 12
1380 PRINT USING C5$;A(I,J);:NEXT J
1390 PRINT:K=L+1:IF K=13 THEN INPUT "ENTER TO PAGE";DU$:K=0
1400 NEXT I
1410 INPUT "HARD COPY OF RESULTS (Y/N)";P$:IF P$<>"Y" THEN 1490
1420 IF NC$="C" THEN LPRINT "FULL CRASH TIMER ANALYSIS"
1430 LPRINT " ":LPRINT Z1$:LPRINT Z2$
1440 FOR I=1 TO M%
1450 LPRINT USING C2$;A$(I,1),A$(I,2);
1460 FOR J=7 TO 12
1470 LPRINT USING " #####.##";A(I,J);:NEXT J
1480 LPRINT " ":NEXT I
1490 PRINT "OUTPUT MENU"
1500 PRINT "     C     Cost and time of Critical Path"
1510 PRINT "     D     Disk"
1520 PRINT "     E     End"
1530 PRINT "     R     Recycle"
1540 PRINT "     S     Selective Crashing"
1560 INPUT "  Selection ";OP$:IF OP$="R" THEN 480
1570 IF OP$ <>"S" THEN 1760
1580 IF NC$<>"N" THEN INPUT "Cannot Crash from full Crash  Enter to Continue";DU$:GOTO 1490
1590 PRINT CHR$(26):PRINT "Selective Crashing -- Starts from Normal Run **": INPUT " New run (Y/N) ";DU$: IF DU$="Y" THEN FOR I=1 TO M%: A(I,13)=0:A(I,7)=A(I,3): NEXT I
1600 PRINT "NO CODE DESCRIPTION    SELECT  CRASH     UNIT    TOTAL"
1610 PRINT "                        TIME   COST      COST    COST"
1620 J=0: FOR I=1 TO M%: IF A(I,13)=0 AND A(I,12)>.00001 THEN 1650
1630 X=(A(I,6)-A(I,4))/(A(I,3)-A(I,5)):PRINT USING C1$;I;:PRINT USING C2$;A$(I,1),A$(I,2);:PRINT USING C3$;A(I,7),A(I,13),X,A(I,6)-A(I,4)
1640 J=J+1: IF J=13 THEN J=0: INPUT "ENTER TO PAGE ";DU$
1650 NEXT I
1660 INPUT "-1 TO CONTINUE OR NUMBER TO CHANGE";IZ:IF IZ=-1 THEN 1700
1670 INPUT "CRASH DOLLARS OVER NORMAL DOLLARS";CD:X=A(IZ,3)-A(IZ,5):TS=CD/((A(IZ,6)-A(IZ,4))/X):IF TS>X THEN S=X: INPUT "WASTED MONEY -- ENTER TO CONTINUE";DU$
1680 A(IZ,13)=CD:A(IZ,7)=A(IZ,7)-TS: IF A(IZ,7)<A(IZ,5) THEN A(IZ,7)=A(IZ,5): INPUT "OVER CRASHED -- ENTER TO CONTINUE";DU$
1690 GOTO 1600
1700 INPUT "HARD COPY (Y/N)";DU$:IF DU$="N" THEN 1010
1710 LPRINT "NO CODE DESCRIPTION   SELECT  CRASH    UNIT  TOTAL"
1720 LPRINT "                       TIME    COST    COST  COST"
1730 J=0: FOR I=1 TO M%: IF A(I,13)=0 AND A(I,12)>.00001 THEN 1750
1740 X=(A(I,6)-A(I,4))/A(I,3)-A(I,5)): LPRINT USING C1$;I;:LPRINT USING C2$;A$(I,1),A$(I,2);:LPRINT USING C3$;A(I,7),A(I,13),X,A(I,6)-A(I,4): J=J+1: IF J=13 THEN J=0: INPUT "ENTER TO CONTINUE";DU$
1750 NEXT I: GOTO 1010
1760 IF OP$<> "C" THEN 1910
1770 REM IDENTIFICATION OF CRITICAL PATH COSTS
1780 CO=0:PATH$=" ":CX=0:CY=0:CZ=0:CP=0:CW=0
1790 FOR I=1 TO M%: IF A(I,12)>.00001 THEN 1810: REM 0 DEFINED AS .00001 ...
1800 CO=CO+A(I,3):PATH$=PATH$+" "+A$(I,1):CX=CX+A(I,4):CY=CY+A(I,6):CZ=CZ+A(I,7):CP=CP+A(I,5):CW=CW+A(I,13)
1810 NEXT I: C6$="###,###,###.##":IF NC$="C" THEN CW=CY-CX
1820 PRINT CHR$(26):PRINT "CRITICAL PATH";:PRINT PATH$
1830 PRINT "TIME OF CRITICAL PATH ";CZ:PRINT "COST OF CRITICAL PATH ";CW+CX,"INCREMENTAL COST ";CW:PRINT "NORMAL TIME CRITICAL PATH ";CO
1840 PRINT "NORMAL COST OF CRITICAL PATH ";CX
1850 PRINT "FULL CRASH TIME OF CRITICAL PATH ";CP:PRINT "FULL CRASH COST OF CRITICAL PATH ";CY
1860 INPUT "HARD COPY (Y/N)";P$:IF P$<>"Y" THEN 1490
1870 LPRINT " ": LPRINT "CRITICAL PATH ";PATH$
1880 LPRINT "TIME OF CRITICAL PATH ";CZ:LPRINT "COST OF CRITICAL PATH ";CW+CX," INCREMENTAL COST ";CW: LPRINT "NORMAL TIME OF CRITICAL PATH ";CO
1890 LPRINT "NORMAL COST OF CRITICAL PATH ";CX
1900 LPRINT "FULL CRASH TIME OF CRITICAL PATH ";CP:LPRINT "FULL CRASH COST OF CRITICAL PATH ";CY: GOTO 1490
1910 IF OP$="E" THEN END
1920 IF OP$<>"D" THEN 2010
1930 INPUT "NAME OF FILE:DISK ";X$:OPEN"O",1,X$
1940 PRINT #1,M%,EE
1950 FOR I=1 TO M%: PRINT #1,CHR$(34);A$(I,1);CHR$(34);",";CHR$(34);A$(I,2);CHR$(34);A(I,1);A(I,2);A(I,3);A(I,4);A(I,5);A(I,6):NEXT I
1960 CLOSE 1: GOTO 1490
2010 GOTO 1490
2020 REM PUT DATA HERE FIRST # ACTIVITIES THEN ENDING EVENT NUMBER THEN CODE, DESCRIPTION, BEGINNING EVENT, ENDING EVENT, NORMAL TIME, COST AND CRASH TIME, COST FOR EACH ACTIVITY
2030 DATA 18,9
2040 DATA A,ACCT. PAPERS,1,2,2,20,1,30
2050 DATA Z,PERMITS,2,7,5,50,4,80
2060 DATA B,SHOP BANKERS,1,3,4,40,3,60
2070 DATA C,SHOP REAL EST.,1,4,13,130,10,170
2080 DATA D,MARKET STUDY,2,3,4,40,3,50
2090 DATA G,CONTRACTOR,2,5,2.2,22,1.7,67
2100 DATA F,INSURANCE,2,6,1.3,13,.5,15
2110 DATA H,ART. PLANS,3,5,4,40,3,60
2120 DATA E,COST STUDY,3,4,4,40,3,50
2130 DATA I,LAND,4,5,11,110,10,130
2140 DATA J,MATERIAL,5,6,3,30,2,40
2150 DATA K,PLANS,5,7,5,50,2,120
2160 DATA L,SURVEY,5,8,2,20,1,40
2170 DATA M,BUY MAT #1,6,8,7,30,4,40
2180 DATA O,BUY MAT #2,6,9,8,20,5,50
2190 DATA N,LAYOUT,7,8,21,110,12,120
2200 DATA P,FOUNTATION,8,9,9,30,6,60
2210 DATA Q,HIRE CREW 2,7,9,2,20,1,30
,8,20,5,50
