Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-01 - 43,50144/cpm.bas
There are 2 other files named cpm.bas in the archive. Click here to see a list.
1000	DATA 4E37,4E37,4E37,4E37
1040	DIM A(7,90),P(90),K(10)
1050	FOR L=1 TO 10000
1060	READ A(1,L),A(2,L),A(3,L),A(4,L)
1090	IF A(1,L)=4E37 THEN 1140
1100	LET A(4,L)=A(4,L)+1
1110	NEXT L
1120	PRINT"TOO MANY ACTIVITIES."
1130	GOTO 2100
1140	IF L=1 THEN 2110
1142	IF A(1,L)=A(4,L) THEN 1156
1144	PRINT "ALL DATA NOT IN FORM   X  I,J,D,A   WHERE:"
1146	PRINT "X=LINE NUMBER(BETWEEN 1 AND 1000)"
1148	PRINT "I=STARTING EVENT FOR ACTIVITY"
1150	PRINT "J=ENDING EVENT FOR ACTIVITY"
1152	PRINT "D=DURATION OF ACTIVITY"
1154	PRINT "A=COST OF ACTIVITY"
1156	Q8=0
1158	L=L-1
1160	LET E=-1
1170	FOR K=1 TO L
1180	FOR M=1 TO L
1190	IF A(1,K)=A(2,M) THEN 1230
1200	NEXT M
1210	IF E>-1 THEN 1400
1220	LET E=K
1230	NEXT K
1240	LET E0=-1
1250	FOR K=1 TO L
1260	FOR M=1 TO L
1270	IF A(2,K)=A(1,M) THEN 1310
1280	NEXT M
1290	IF E0>-1 THEN 1480
1300	LET E0=K
1310	NEXT K
1320	LET E1=-1
1330	FOR K=1 TO L
1340	FOR M=K+1 TO L
1350	IF A(1,K)<>A(1,M) THEN 1370
1360	IF A(2,K)= A(2,M) THEN 1560
1370	NEXT M
1380	NEXT K
1390	GOTO 1630
1400	IF E=0 THEN 1460
1410	IF A(1,K)=A(1,E) THEN 1230
1420	PRINT
1430	PRINT "MULTIPLE STARTS:"
1440	PRINT E;A(1,E);A(2,E)
1450	LET E=0
1460	PRINT K;A(1,K);A(2,K)
1470	GOTO 1230
1480	IF E0=0 THEN 1540
1490	IF A(2,K)=A(2,E0) THEN 1310
1500	PRINT
1510	PRINT "MULTIPLE ENDS:"
1520	PRINT E0;A(1,E0);A(2,E0)
1530	LET E0=0
1540	PRINT K;A(1,K);A(2,K)
1550	GOTO 1310
1560	IF E1=0 THEN 1600
1570	PRINT
1580	PRINT"DUPLICATE ACTIVITIES:"
1590	LET E1=0
1600	PRINT K;A(1,K);A(2,K);A(3,K);A(4,K)
1610	PRINT M;A(1,M);A(2,M);A(3,M);A(4,M)
1620	GOTO 1370
1630	IF E=0 THEN 2100
1640	IF E0=0 THEN 2100
1650	IF E1=0 THEN 2100
1660	A(1,L+1)=A(1,E)
1670	LET P(1)=E
1680	A(2,L+1)=A(2,E0)
1690	LET E=A(2,P(1))
1700	A(3,L+1)=-1
1710	LET L1=2
1720	LET F=1
1730	X=1
1740	LET S=0
1750	GOTO 1780
1760	LET S=0
1770	X=L1
1780	FOR K=F TO L
1790	IF A(1,K)<>E THEN 1900
1800	IF A(4,K)<0 THEN 1900
1810	LET S=1
1820	LET E=A(2,K)
1830	LET P(L1)=K
1840	FOR P1=1 TO L1-1
1850	IF P(P1)=P(L1) THEN 2040
1860	NEXT P1
1870	LET L1=L1+1
1880	LET F=1
1890	GOTO 1780
1900	NEXT K
1910	LET L1=L1-1
1920	IF L1<2 THEN 2150
1930	LET Q=P(L1)
1940	LET A(4,Q)=-A(4,Q)
1950	LET E=A(2,P(L1-1))
1960	LET F=P(L1)+1
1970	IF S=0 THEN 1770
1980	IF Q8=0 THEN 1760
1990	FOR M=X TO X2
2000	PRINT A(1,P(M));A(2,P(M))
2010	NEXT M
2020	PRINT 
2030	GOTO 1760
2040	PRINT
2050	PRINT "LOGIC LOOP:"
2060	FOR N=P1 TO L1
2070	PRINT P(N);
2080	PRINT A(1,P(N));A(2,P(N))
2090	NEXT N
2100	STOP
2110	PRINT "LIST THE FILE 'CPMEXP*' FOR INSTRUCTIONS."
2120	STOP
2130	LET K(1)=1
2131	LET K(2)=2
2132	LET K(3)=3
2133	LET K(4)=5
2134	LET K(5)=9
2135	LET K(6)=11
2136	LET K(7)=6
2137	LET K(8)=10
2138	LET K(9)=7
2139	LET K(10)=4
2150	FOR K=1 TO L
2160	A(4,K)=ABS(A(4,K))-1
2170	NEXT K
2180	LET I=1
2190	N=L+1
2200	LET J=2
2210	LET D=3
2220	LET L0=6
2230	LET E5=5
2240	LET D0=4
2250	LET L=7
2260	LET T3=0
2270	FOR K=1 TO N-1
2280	LET T3=T3+A(D0,K)
2290	LET A(L0,K)=-1
2300	LET A(E5,K)=-1
2310	NEXT K
2320	GOSUB 2900
2330	GOSUB 3480
2340	LET E1=N
2350	PRINT
2360	PRINT "WHAT COLUMN FOR SORT, AND HOW MANY ACTIVITIES";
2370	INPUT Y,E1
2380	IF Y=0 THEN 2470
2390	E1=E1+1
2400	IF E1 <= N THEN 2420
2410	LET E1=N
2420	IF E1<=1 THEN 2440
2430	GOSUB 3300
2440	LET Y=K(Y)
2450	GOSUB 3090
2460	GOTO 2350
2470	PRINT
2480	PRINT "WHAT ACTIVITY";
2490	INPUT A,B
2500	FOR K=1 TO N-1
2510	IF A<>A(I,K) THEN 2560
2520	IF B<>A(J,K) THEN 2560
2530	GOSUB 3300
2540	GOSUB 2980
2550	GOTO 2350
2560	NEXT K
2570	PRINT "NO SUCH ACTIVITY DEFINED."
2580	GOTO 2350
2590	STOP
2600	FOR B=1 TO N
2610	IF C5<>A(I,B) THEN 2650
2620	LET A(L,B)=C1+1
2630	 IF C4<=A(Y,B) THEN 2650
2640	LET A(Y,B)=C4
2650	NEXT B
2660	RETURN
2670	LET F=0
2680	LET C5=A(I,N)
2690	LET C1=1
2700	LET C4=0
2710	FOR K=1 TO N-1
2720	LET A(L,K)=-1
2730	NEXT K
2740	GOSUB 2600
2750	LET C1=2
2760	LET S=0
2770	FOR A=1 TO N
2780	IF A(L,A)<>C1 THEN 2860
2790	 LET S=1
2800	LET A(L,A)=A(L,A)-1
2810	LET C5=A(J,A)
2820	LET C4=A(Y,A)+A(D,A)
2830	IF C4<=F THEN 2850
2840	LET F=C4
2850	GOSUB 2600
2860	NEXT A
2870	LET C1=C1+1
2880	IF S=1 THEN 2760
2890	RETURN
2900	I=2
2910	J=1
2920	Y=L0
2930	GOSUB 2670
2940	FOR K=1 TO N
2950	A(Y,K)=F-A(Y,K)
2960	NEXT K
2970	RETURN
2980	E6=A(E5,K)+A(D,K)
2990	T1=A(L0,K)-E6
3000	L5=A(L0,K)-A(D,K)
3010	IF T1=0 THEN 3040
3020	PRINT "   ";
3030	GOTO 3050
3040	PRINT " * ";
3050	PRINT TAB(5);A(I,K);TAB(10);A(J,K);
3060	PRINT TAB(16);A(D,K);TAB(21);A(E5,K);TAB(27);E6;TAB(33);L5;
3070	PRINT TAB(39);A(L0,K);TAB(45);T1;TAB(51);A(L,K);TAB(58);A(D0,K)
3080	RETURN
3090	 LET A=1
3100	FOR B=N-1 TO A+1 STEP -1
3110	LET X9=B-1
3120	GOSUB 3370
3130	LET X8=X9
3140	LET X9=B
3150	GOSUB 3370
3160	IF X8<=X9 THEN 3220
3170	FOR K=1 TO 7
3180	LET A(K,N+1)=A(K,B)
3190	LET A(K,B)=A(K,B-1)
3200	LET A(K,B-1)=A(K,N+1)
3210	NEXT K
3220	NEXT B
3230	IF E1=1 THEN 3270
3240	IF E1<A+1 THEN 3270
3250	LET  K=A
3260	GOSUB 2980
3270	LET A=A+1
3280	IF A<N THEN 3100
3290	RETURN
3300	PRINT
3310	PRINT "PROJECT DURATION:";F,"TOTAL COST. $";T3
3320	PRINT
3330	PRINT "CRIT  I    J    DUR   ES    EF    LS    LF    TF";
3340	PRINT "   LEV     $"
3350	PRINT
3360	RETURN
3370	IF Y<8 THEN 3440
3380	IF Y=9 THEN 3460
3390	LET X7=0
3400	IF Y<>10 THEN 3420
3410	LET X7=A(E5,X9)
3420	LET X9=A(L0,X9)-A(D,X9)-X7
3430	RETURN
3440	LET X9=A(Y,X9)
3450	RETURN
3460	LET X9=A(E5,X9)+A(D,X9)
3470	RETURN
3480	LET I=1
3490	LET J=2
3500	LET Y=E5
3510	GOSUB 2670
3520	RETURN
3530	END