10 CLEAR 1000:PRINT CHR$(26): REM  PERTSAMP.BAS
20 PRINT "PERT/CRITICAL PATH SCHEDULING PROGRAM"
30 PRINT "BY STEVEN ZIMMERMAN AND LEO M. CONRAD"
40 PRINT "MODIFIED FOR THE OSBORNE 1 BY D. M. HURST, 1982"
85 WIDTH 128
100 PRINT:PRINT "*** NOTE BEGINNING EVENTS WILL BE SORTED ***"
110 PRINT"        *** INTO NUMERICAL ORDER   ***":PRINT
111 PRINT:INPUT "TIME UNITS WILL BE MEASURED IN ";DWM$
113 PRINT:INPUT "PROJECT START DATE IS (MM/DD/YY) ";ST$
115 ON ERROR GOTO 119
117 READ D%:DIM A$(D%,2),A(D%,11),SV(11):RESTORE:IO$="R":GOTO 230
119 RESUME 120
120 PRINT:PRINT "      !!!          WARNING          !!!"
130 PRINT:PRINT "NO DATA READ STARTING AT LINE 4000. AM ASSUMING"
140 PRINT "DATA TO BE ENTERED FROM KEYBOARD OR DISK FILE."
150 PRINT:PRINT "ENTER TOTAL NUMBER OF ACTIVITIES (ALLOW EXTRA"
152 INPUT "FOR ANTICIPATED ADDITIONS) ";D%:PRINT
160 DIM A$(D%,2),A(D%,11),SV(11)
170 KK$="N"
180 PRINT "INPUT MENU"
190 PRINT"     K    KEYBOARD"
200 PRINT"     D    DISK FILE"
220 INPUT "SELECTION";IO$
230 IF IO$<>"K" THEN 310
240 PRINT CHR$(26):M%=D%:EE=0
250 PRINT"THIS IS GOING TO BE WORK YOU MUST NOW INPUT"
252 PRINT "UP TO ";M%;" ACTIVITIES.":PRINT
260 FOR I=1 TO M%
270 INPUT "ACTIVITY CODE ";A$(I,1)
280 INPUT "DESCRIPTION ";A$(I,2)
281 INPUT "BEGINNING EVENT ";A(I,1)
282 INPUT "ENDING EVENT ";A(I,2)
283 INPUT "OPTIMISTIC TIME ";A(I,3)
284 INPUT "LIKELY TIME ";A(I,4)
285 INPUT "PESSIMISTIC TIME ";A(I,5)
286 PRINT:IF I<M% THEN PRINT "NEXT ACTIVITY":PRINT
290 NEXT I
300 GOTO 470
310 IF IO$<>"D" THEN 400
320 LINE INPUT "NAME OF Drive:Fn.Ft ";B$: REM DISK INPUT
330 OPEN "I",1,B$
340 INPUT#1 ,M%,EE
350 FOR I = 1 TO M%
360 INPUT#1,A$(I,1),A$(I,2),A(I,1),A(I,2),A(I,3),A(I,4),A(I,5)
370 NEXT I
380 CLOSE 1
390 GOTO 470
400 IF IO$<>"R" THEN 160
410 READ M%,EE
420 FOR I=1 TO M%:REM READ INPUT
430  READ A$(I,1),A$(I,2),A(I,1),A(I,2),A(I,3),A(I,4),A(I,5)
440 IF A$(I,1) ="END" THEN 470
450 NEXT I
460 REM PRINTS INPUT DATA FOR VERIFICATION
470 M=M%: TP=0:FOR I=1 TO M: IF A(I,2)>TP THEN TP=A(I,2)
480 NEXT I:EE=TP
490 FOR I=1 TO M-1
500 FOR J=I+1 TO M
510 IF A(I,1)<=A(J,1) THEN 540
520 FOR K=1 TO 11:SV(K)=A(I,K):A(I,K)=A(J,K):A(J,K)=SV(K):NEXT K
530 FOR K =1 TO 2:SV$(K)=A$(I,K):A$(I,K)=A$(J,K):A$(J,K)=SV$(K):NEXT K
540 NEXT J,I
550 XX=5:PRINT CHR$(26):PRINT "VERIFICATION OF INPUT"
560 Z1$="CODE DESCRIPTION       EXPECTED  EARLY   EARLY    LAST    LAST   SLACK"
570 Z2$="                          TIME   START     FIN   START     FIN    TIME"
580 Z3$="CODE DESCRIPTION       BEGIN  END  OPTIMIST LIKELY  PESSI"
590 Z4$="                         EVENT EVENT   TIME    TIME    TIME"
600 PRINT " NO ";Z3$
610 PRINT "  ";Z4$
620 K=0
630 C4$="###"
640 FOR I = 1 TO M%
650 PRINT USING C4$;I;
660 C1$ =" #### "
670 C2$ =" \ \\                \":C3$=" ####.##"
680 PRINT USING C2$;A$(I,1),A$(I,2);
690 FOR J=1 TO 2
700 PRINT USING C1$;A(I,J);:NEXT J
710 FOR J=3 TO 5
720 PRINT USING C3$;A(I,J);:NEXT J
730 K=K+1:IF K>13 THEN PRINT :INPUT "ENTER TO PAGE";DU$:K=0
740 PRINT :NEXT I
750 INPUT "-2 TO ADD, -1 TO CONTINUE OR NUMBER TO CHANGE";L:IF L=-1 THEN 800
760 IF L<>-2 THEN 780
770 L=M%+1:M%=L:N%=N%+1
780 PRINT CHR$(26):PRINT" ENTER CHANGE/ADD DATA":PRINT
781 INPUT "ACTIVITY CODE ";A$(L,1)
782 INPUT "DESCRIPTION ";A$(L,2)
783 INPUT "BEGINNING EVENT ";A(L,1)
784 INPUT "ENDING EVENT ";A(L,2)
785 INPUT "OPTIMISTIC TIME ";A(L,3)
786 INPUT "LIKELY TIME ";A(L,4)
787 INPUT "PESSIMISTIC TIME ";A(L,5)
790 GOTO 470
800 INPUT "HARD COPY OF INPUT DATA (Y/N)";P$:WIDTH LPRINT 132
810 IF P$<>"Y" THEN 980
811 LPRINT:LPRINT:LPRINT "PERT/CRITICAL PATH SHEDULING PROGRAM"
812 LPRINT "BY STEVEN ZIMMERMAN AND LEO M. CONRAD"
813 LPRINT "MODIFIED FOR THE OSBORNE 1 BY D. M. HURST, 1982"
814 LPRINT
820 INPUT "TITLE";T$:LPRINT "TITLE:  ";T$
830 INPUT "DATE";TT$:LPRINT "DATE:  ";TT$
840 LPRINT "TIME IS IN ";DWM$
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 5
930 LPRINT USING C3$;A(I,J);:NEXT J
940 LPRINT "  "
950 NEXT I
960 LPRINT CHR$(12)
970 REM FORWARD PASS
980 FOR I=1 TO M%
990 A(I,6)=(A(I,3)+4*A(I,4)+A(I,5))/6
1000 IF A(I,1)=1 THEN A(I,7)=0:A(I,8)=A(I,6):GOTO 1080
1010 MAX=0!
1020 FOR J=1 TO M%
1030 IF A(J,2)<>A(I,1) THEN 1060
1040 IF A(J,8)>MAX THEN MAX = A(J,8)
1050 A(I,7)=MAX
1060 NEXT J
1070 A(I,8)=A(I,7)+A(I,6)
1080 NEXT I
1090 REM BACKWARD PASS
1100 XM=0!
1110 FOR I=M% TO 1 STEP -1
1120 IF A(I,2)<>EE THEN 1140
1130 IF XM<A(I,8) THEN XM=A(I,8)
1140 NEXT I
1150 FOR I=M% TO 1 STEP -1
1160 IF A(I,2)=EE THEN A(I,10) = XM: GOTO 1230
1170 MIM=99999!
1180 FOR J=M% TO 1 STEP -1
1190 IF A(I,2)<>A(J,1) THEN 1220
1200 IF A(J,9)<MIM THEN MIM=A(J,9)
1210 A(I,10)=MIM
1220 NEXT J
1230 A(I,9)=A(I,10)-A(I,6)
1240 REM SLACK VARIABLE CALCULATIONS
1250 NEXT I
1260 FOR I =1 TO M%
1270 A(I,11)=A(I,10)-A(I,8)
1280 NEXT I
1290 IF KK$="Y" THEN 2300
1300 REM PRINT OUTPUT
1310 K=0
1320 PRINT "CODE DESCRIPTION      EXPECTED   EARLY   EARLY    LAST    LAST   SLACK"
1330 PRINT "                          TIME   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=6 TO 11
1380 PRINT USING C5$;A(I,J);:NEXT J
1390 PRINT :K=K+1:IF K=13 THEN INPUT "ENTER TO PAGE";DU$:K=0
1400 NEXT I
1410 INPUT "HARDCOPY OF RESULTS (Y/N)";P$:IF P$<>"Y" THEN 1500
1420 LPRINT " ":LPRINT Z1$:LPRINT Z2$
1430 FOR I=1 TO M%
1440 LPRINT USING C2$;A$(I,1),A$(I,2);
1450 FOR J=6 TO 11
1460 LPRINT USING C3$;A(I,J);: NEXT J
1470 LPRINT " ":NEXT I
1480 LPRINT CHR$(12)
1500 K=0
1505 IF LEFT$(DWM$,1)="W" THEN 1510 ELSE IF LEFT$(DWM$,1)="M" THEN 1540 ELSE 2300
1510 PRINT:PRINT "                             GANNT CHART FOR ";T$;" IN WEEKS";"      START DATE ";ST$
1515 PRINT "                                              YEAR #1                                              YEAR #2"
1520 PRINT "                       12345678911111111112222222222333333333344444444445551234567891111111111222222222233333333334444444444555"
1530 PRINT "                                0123456789012345678901234567890123456789012         0123456789012345678901234567890123456789012":GOTO 1580
1540 PRINT "                                   GANNT CHART FOR ";T$;" IN MONTHS";"      START DATE ";ST$
1550 PRINT "                          YR#1        YR#2        YR#3        YR#4        YR#5"
1560 PRINT "                       123456789111123456789111123456789111123456789111123456789111"
1570 PRINT "                                012         012         012         012         012"
1580 PRINT:PRINT CHR$(27)"l"
1590 FOR I=1 TO M%
1600 FOR J=6 TO 11
1610 A(I,J)=INT(A(I,J))
1620 NEXT J
1630 NEXT I
1640 FOR I=1 TO M%
1645 IF A(I,10)+25 > 128 THEN PRINT CHR$(27)"m";"NOT ENOUGH ROOM FOR SCREEN PRINT":GOTO 2000
1650 PRINT USING C2$;A$(I,1),A$(I,2);
1660 PRINT TAB(A(I,7)+24);"E";
1670 FOR J=1 TO (A(I,6)-1)
1680 IF A(I,11)=0 THEN PRINT "C"; ELSE PRINT "@";
1690 NEXT J
1700 IF A(I,11)=0 THEN PRINT TAB(A(I,7)+A(I,6)+24);"L" ELSE PRINT TAB(A(I,10)+24);"L"
1705 K=K+1:IF K=13 THEN PRINT CHR$(27)"m";"ENTER TO PAGE";:INPUT DU$:PRINT CHR$(27)"l":K=0
1710 NEXT I
1720 PRINT CHR$(27)"m"
1730 PRINT:PRINT "E = EARLIEST START FOR AN ACTIVITY"
1740 PRINT        "C & @ = EXPECTED TIME FOR AN ACTIVITY WITH C DESIGNATING THOSE ON THE CRITICAL PATH"
1750 PRINT        "L = LAST FINISH FOR AN ACTIVITY WITHOUT EXTENDING THE TIME OF THE CRITICAL PATH"
1760 PRINT:PRINT
2000 INPUT"DO YOU WANT A GANNT CHART PRINTOUT (Y/N)";KK$
2020 IF KK$="Y" AND LEFT$(DWM$,1)="W" THEN 2023 ELSE IF KK$="Y" AND LEFT$(DWM$,1)="M" THEN 2060 ELSE KK$="Y":GOTO 2290
2023 IF LEFT$(DWM$,1)="W" THEN LPRINT CHR$(15)
2030 LPRINT "                             GANNT CHART FOR ";T$;" IN WEEKS";"      START DATE ";ST$
2035 LPRINT "                                               YEAR #1                                              YEAR #2"
2040 LPRINT "                       12345678911111111112222222222333333333344444444445551234567891111111111222222222233333333334444444444555"
2050 LPRINT "                                0123456789012345678901234567890123456789012         0123456789012345678901234567890123456789012":GOTO 2100
2060 LPRINT "                                   GANNT CHART FOR ";T$;" IN MONTHS";"      START DATE ";ST$
2070 LPRINT "                          YR#1        YR#2        YR#3        YR#4        YR#5"
2080 LPRINT "                       123456789111123456789111123456789111123456789111123456789111"
2090 LPRINT "                                012         012         012         012         012"
2100 LPRINT:LPRINT CHR$(27)"-"CHR$(1)
2110 FOR I=1 TO M%
2115 IF A(I,10)+25 > 128 THEN PRINT CHR$(27)"m";"NOT ENOUGH ROOM FOR 8 1/2 INCH  PRINT":LPRINT CHR$(12);CHR$(18);CHR$(27)"-"CHR$(0):GOTO 2300
2120 FOR J=6 TO 11
2130 A(I,J)=INT(A(I,J))
2140 NEXT J
2150 NEXT I
2160 FOR I=1 TO M%
2170 LPRINT USING C2$;A$(I,1),A$(I,2);
2180 LPRINT TAB(A(I,7)+24);"E";
2190 FOR J=1 TO (A(I,6)-1)
2200 IF A(I,11)=0 THEN LPRINT "C"; ELSE LPRINT "@";
2210 NEXT J
2220 IF A(I,11)=0 THEN LPRINT TAB(A(I,7)+A(I,6)+24);"L" ELSE LPRINT TAB(A(I,10)+24);"L"
2230 NEXT I
2235 IF LEFT$(DWM$,1)="W" THEN LPRINT CHR$(18)
2240 LPRINT CHR$(27)"-"CHR$(0)
2250 LPRINT:LPRINT "E = EARLIEST START FOR AN ACTIVITY"
2260 LPRINT        "C & @ = EXPECTED TIME FOR AN ACTIVITY WITH C DESIGNATING THOSE ON THE CRITICAL PATH"
2270 LPRINT        "L = LAST FINISH FOR AN ACTIVITY WITHOUT EXTENDING THE TIME OF THE CRITICAL PATH"
2280 LPRINT CHR$(12)
2290 GOTO 970
2300 PRINT "OUTPUT MENU"
2310 PRINT "    C     CRITICAL PATH AND TIME"
2320 PRINT "    D     DISK"
2330 PRINT "    E     END"
2340 INPUT "    R     RECYCLE   SELECTION";OP$:IF OP$="R" THEN KK$="N":GOTO 470
2350 IF OP$<> "C" THEN 2520
2360 REM IDENTIFICATION OF CRITICAL PATH AND COSTS
2370 CO=0:PATH$="  ":SI=0
2380 FOR I=1 TO M%: IF A(I,11)>.001 THEN 2400:REM NOTE >0 SHOULD WORK BUT .0001 USED
2390 CO=CO+A(I,6):PATH$=PATH$+"  "+A$(I,1):SI=SI+((A(I,3)-A(I,5))/6)^2
2400 NEXT I:C6$="###,###,###.##":SI=SQR(SI)
2410 PRINT CHR$(26):PRINT "CRITICAL PATH":PRINT PATH$:PRINT
2420 PRINT "TIME OF CRITICAL PATH":PRINT USING C6$;CO:INPUT "SCHEDULED PROJECT TIME(USE SAME TIME UNITS AS DATA)";ST:Z=(ST-CO)/SI:XX=0
2430 BB$="PROBABILITY OF BEING COMPLETED ON TIME":IF Z<0 THEN 2470
2440 A=.436184:B=-.120168:C=.937298:D=(2.7182818# ^ (-Z^2/2))*(2*3.1415926#)^(-.5):E=(1+.3326*Z)^(-1):P=1-D*(A*E+B*E^2+C*E^3):IF XX>0 THEN 2460 :REM TAYLOR SERIES
2450 PRINT "Z= ";Z,BB$;P: GOTO 2480
2460 PRINT "Z= ";-Z,BB$;1-P:GOTO 2480
2470 XX=99:Z=-Z:GOTO 2440
2480 INPUT "HARD COPY (Y/N)";P$:IF P$<>"Y" THEN 2300
2490 WIDTH LPRINT 84:LPRINT " ":LPRINT "CRITICAL PATH":LPRINT PATH$:LPRINT " ":LPRINT "SCHEDULED PROJECT TIME IS ";ST
2500 LPRINT "TIME OF CRITICAL PATH":LPRINT USING C6$;CO:IF XX=0 THEN LPRINT "Z= ";Z,BB$;P:GOTO 2300
2510 LPRINT "Z= ";-Z,BB$;1-P:GOTO 2300
2520 IF OP$="E" THEN END
2530 LINE INPUT "NAME OF FILE: DISK  ";X$:OPEN "O",1,X$
2540 PRINT #1,M%,EE
2550 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):NEXT I
2560 CLOSE 1:GOTO 2300
2570 REM "THE REMAINDER OF THE PROGRAM WILL CONSIST" 
2580 REM "OF DATA TO BE READ IN. STARTING AT 4000  "
2590 REM "ENTER # OF ACTIVITIES AND ENDING EVENT # "
2600 REM "AS    -----4000 DATA 15,4-----                  "
2610 PRINT
2620 REM "THEN LIST ACTIVITY,DESCRIPTION,STARTING"
2630 REM "EVENT#,ENDING EVENT#, OPTIMISTIC TIME, "
2640 REM "LIKELY TIME, AND PESSIMISTIC TIME-AS   "
2650 REM " ---4010 DATA A,MAKE HASTE,2,5,3,4,6---"
#, OPTIMISTIC TIME, "
2640 REM "LIKELY TIME, AND PESSIMISTIC TIME-AS   "
2650 REM " ---4010 DATA A,MAKE HASTE,2,5,3,4,6---"
