10	! YEARTAB.BAS,BA8
	! PROGRAM TO PRINT CROSS TABULATIONS FOR PROGRAMMER
	! TIME ACCOUNTING INFO.  THIS PROGRAM ASSUMES EXISTENCE
	! OF VIRTUAL ARRAY CREATED BY PROGYEAR FOR THE FISCAL YEAR
	! IN QUESTION.
100 DEF FNSU(PJ,MO,PG)=(PJ*13+MO)*11+PG
160 DIM PD(12,10),UD(12,60),UP(60,10)
200 DIM #16,PR%(9394)
210	PJ=50		! DEFINE NUMBER OF PROJECTS
	LM=5		! DEFINE LEFT MARGIN
	P1=2 : P2=6	! DEFINE LOWER, UPPER BOUNDS ON PROGRAMMER NUMBERS
600	 ! ASK USER FOR FISCAL YEAR OF STATEMENT
610 INPUT "FISCAL YEAR (YY) "; YY
630 FY&=YY	! FISCAL YEAR
650 D1=DCEN("07/01/"+STR$(FY&-1))		! FIRST DAY OF FISCAL YEAR
	D2=DCEN("06/30/"+STR$(FY&))		! LAST  DAY OF FISCAL YEAR
700 OPEN #16,"YEAR"+STR$(FY&)+".VPG/RO/BL"
710 OPEN #3,"YEAR"+STR$(FY&)+".PGA/WR/LN:132"
1000 ! ZERO ARRAYS
1010 FOR J=0 TO 12 : FOR K=0 TO 10 : PD(J,K)=0 : NEXT K,J
1020 FOR J=0 TO 12 : FOR I=0 TO 60 : UD(J,I)=0 : NEXT I,J
1030 FOR I=0 TO 60 : FOR K=0 TO 10 : UP(I,K)=0 : NEXT K,I
1100 ! ACCUMULATE TOTALS
1110 FOR I=1 TO PJ
1120 FOR J=1 TO 12
1130 FOR K=P1 TO P2
1140 HR=PR%(FNSU(I,J,K))/100
1150 IF HR <> 0 THEN
	PD(J,K)=PD(J,K)+HR : PD(0,K)=PD(0,K)+HR : PD(J,0)=PD(J,0)+HR : PD=PD+HR:
	UD(J,I)=UD(J,I)+HR : UD(0,I)=UD(0,I)+HR : UD(J,0)=UD(J,0)+HR : UD=UD+HR:
	UP(I,K)=UP(I,K)+HR : UP(0,K)=UP(0,K)+HR : UP(I,0)=UP(I,0)+HR : UP=UP+HR
1190 NEXT K,J,I
1300 ! PRINT PROGRAMMER VS. MONTH OF YEAR
1310 P=0 : GOSUB 3000
1320 PRINT #3,TAB(LM);"PROGRAMMER ->"
1330 PRINT #3,TAB(LM);"MON OF YR.";TAB(15);
1340 FOR K=P1 TO P2 : PRINT #3,FRMT$(K,8); : NEXT K
1350 PRINT #3,"   TOTAL" : JL=7 : JH=12
1360 FOR J=JL TO JH
1370 PRINT #3,FRMT$(J,LM+3);TAB(15);
1380 FOR K=P1 TO P2 : PRINT #3,FRMT$(PD(J,K),8,2); : NEXT K
1390 PRINT #3,FRMT$(PD(J,0),8,2)
1400 NEXT J : IF JL=1 THEN 1410 ELSE JL=1 : JH=6 : GOTO 1360
1410 PRINT #3,TAB(15); : FOR K=P1 TO P2+1 : PRINT #3," -------"; : NEXT K : PRINT #3
1420 PRINT #3,TAB(15); 
1430 FOR K=P1 TO P2 : PRINT #3,FRMT$(PD(0,K),8,2); : NEXT K:
	PRINT #3,FRMT$(PD,8,2)
1500 ! PRINT PROJECT (USER) VS. MONTH OF YEAR
1540 I1=1 : I2=10 : IT=0 : GOSUB 1600
1545 I1=11: I2=20 : IT=0 : GOSUB 1610
1550 I1=21: I2=30 : IT=0 : GOSUB 1610
1560 I1=31: I2=40 : IT=0 : GOSUB 1600
1570 I1=41: I2=50 : IT=0 : GOSUB 1610
1580 I1=51: I2=PJ : IT=1 : GOSUB 1610
1590 GOTO 1800
1600 GOSUB 3000
1610 PRINT #3,TAB(LM);"PROJECT ->"
1620 PRINT #3,TAB(LM);"MON OF YR.  ";; : IF I2<I1 THEN 1640
1630 PRINT #3,FRMT$(I1,2); : FOR I=I1+1 TO I2 : PRINT #3,FRMT$(I,7); : NEXT I
1640 IF IT=1 THEN PRINT #3,"TOTAL" ELSE PRINT #3
1645 JL=7 : JH=12
1650 FOR J=JL TO JH
1660 PRINT #3,FRMT$(J,LM+3);TAB(12); : IF I2<I1 THEN 1680
1670 FOR I=I1 TO I2 : PRINT #3,FRMT$(UD(J,I),7,2); : NEXT I
1680 IF IT=1 THEN PRINT #3,"  ";FRMT$(UD(J,0),8,2) ELSE PRINT #3
1690 NEXT J : IF JL=1 THEN 1700 ELSE JL=1 : JH=6 : GOTO 1650
1700 PRINT #3,TAB(12); : IF I2<I1 THEN 1720
1710 FOR I=I1 TO I2 : PRINT #3," ------"; : NEXT I
1720 IF IT=1 THEN PRINT #3,"   -------" ELSE PRINT #3
1730 PRINT #3,TAB(LM);"TOTAL";TAB(12); : IF I2<I1 THEN 1750
1740 FOR I=I1 TO I2 : PRINT #3,FRMT$(UD(0,I),7,2); : NEXT I
1750 IF IT=1 THEN PRINT #3,"  ";FRMT$(UD,8,2) ELSE PRINT #3
1760 PRINT #3 : PRINT #3 : RETURN
1800 ! PRINT PROGRAMMER VS. PROJECT
1810 GOSUB 3000 : PRINT #3,TAB(LM);"PROGRAMMER ->"
1820 PRINT #3,TAB(LM);"PROJECT";TAB(15);
1830 FOR K=P1 TO P2 : PRINT #3,FRMT$(K,8); : NEXT K
1840 PRINT #3,"   TOTAL"
1850 FOR I=1 TO PJ
1860 PRINT #3,FRMT$(I,LM+3);TAB(15);
1870 FOR K=P1 TO P2 : PRINT #3,FRMT$(UP(I,K),8,2); : NEXT K
1880 PRINT #3,FRMT$(UP(I,0),8,2)
1890 NEXT I
1900 PRINT #3,TAB(15); : FOR K=P1 TO P2+1 : PRINT #3," -------"; : NEXT K : PRINT #3
1910 PRINT #3,TAB(LM);"TOTAL";TAB(15); : FOR K=P1 TO P2 : PRINT #3,FRMT$(UP(0,K),8,2);:
	NEXT K
1920 PRINT #3,FRMT$(UP,8,2)
2000 CLOSE : EXIT
3000 ! PRINT PAGE HEADER
3010 P=P+1 : PRINT #3,CHR$(12) : PRINT #3
3020 PRINT #3,TAB(LM);"BIOMEDICAL COMPUTER SECTION";
	TAB(68);"FISCAL YEAR - "+STR$(FY&)
3030 PRINT #3,TAB(LM);"MEDICAL PHYSICS DEPARTMENT";TAB(77);"PAGE "+FRMT$(P,2) :
	PRINT #3,TAB(38);"PROGRAMMER ACTIVITY SUMMARY":
	PRINT #3
3040 RETURN
