10	! PROGRAM PROGVIR.BAS
	! TO UPDATE A VIRTUAL ARRAY CONTAINING INDICES INTO
	! PROGRAMMER TIME LOG FILES
	!
	! LAYOUT OF VIRTUAL FILE:
	!	P%(N,24)
	!	N IS NUMBER OF PROGRAMMERS
	!	P%(N,24) IS IS A SET OF INDICES INTO FILE N
	!	P%(N,J*2-1) FOR J=1 TO 12 IS START OF REC FOR FILE N AND MO J
	!	P%(N,J*2)           "        NO.        "            "
	!	P%(N,0) IS RAD50 PROGRAMMER CODE (3 CHAR)
	!	P%=N
50 DEF FNRM(A,B)=A-INT(A/B)*B
60 DEF FND$(R$)=SBS$(R$,48,6)
70 DEF FNMO(R$)=VAL(SBS$(R$,1,2))
90 DIM L$[60]
100 N=6 ! DEFINE NUMBER OF PROGRAMMERS
110 DIM #3,P%(12,24)
120 INPUT LINE "FISCAL YEAR (YY)";YY$
130 IF LEN(YY$)=0 THEN STOP
	ELSE IF LEN(YY$)<>2 THEN 120
140 YY$="F"+YY$
150 ON ERROR GOTO 170
160 OPEN #3,YY$+".VIR/UP/BL" : ON ERROR GOTO 0 : GOTO 500
170 IF FCS(0)<>-26 THEN PRINT "FILE ERROR";FCS(0) : ON ERROR GOTO 0:
	GOTO 120
	ELSE OPEN #3,YY$+".VIR/WR/BL" : ON ERROR GOTO 0
180 DATA FRA,BON,DEA,LAR,BEV,DAN
300 FOR I=1 TO N : READ C$ : P%(I,0)=AR5(C$) : NEXT I
310 FOR I=1 TO N : FOR J=1 TO 24
320 P%(I,J)=0
330 NEXT J,I
350 P%=N
500 FOR NI=1 TO N
510 ON ERROR GOTO 550
520 OPEN #4,"[2,1]LOG"+R5A$(P%(NI,0))+"."+YY$+"/RN/RO/SH/LN:60":
	ON ERROR GOTO 0
530 GOSUB 1000
540 PRINT "LOG"+R5A$(P%(NI,0))+" FINISHED":
	CLOSE 4 : GOTO 570
550 IF FCS(0)=-26 THEN
	PRINT "LOG"+R5A$(P%(NI,0))+" NOT ESTABLISHED":
	CLOSE 4 : ON ERROR GOTO 0:
	GOTO 570
	ELSE PRINT "ERROR";ERR(0);", FCS=";FCS(0);"ON LOG"+R5A$(P%(NI,0))
570 NEXT NI
580 CLOSE 3
600 STOP
1000 ! FOR FILE OPEN ON UNIT 4, UPDATE INFO IN P%(NI,?)
1010 FOR I=1 TO 12:
	IF P%(NI,I*2)>0 THEN 1020
	ELSE 1040
1020 NEXT I
1030 I=I+1
1040 I=I-1 : IF I=0 THEN 1060
1050 IF P%(NI,I*2)+P%(NI,I*2-1)=NRC(4) THEN 1190
	ELSE IF P%(NI,I*2)+P%(NI,I*2-1)-1 > NRC(4) THEN 1060
	ELSE FR%=P%(NI,I*2)+P%(NI,I*2-1) : GOTO 1110
1060 I=1 : FR%=1 : P%(NI,I*2-1)=1 : P%(NI,I*2)=0:
	GOTO 1110
1100 ! DO COUNTING OF RECORDS IN MONTHS
1110 INPUT LINE #4@FR%,L$
1120 IR=FNRM(FNMO(FND$(L$))+6,12)
1130 IF IR <> I THEN 1140
	ELSE P%(NI,I*2)=P%(NI,I*2)+1:
	GOTO 1150
1140 IF IR=I+1 THEN
	I=I+1:
	P%(NI,I*2-1)=FR%:
	P%(NI,I*2)=1:
	GOTO 1150
     ELSE IF IR < I THEN
	PRINT "RECORDS OUT OF SEQUENCE":
	STOP
     ELSE
	I=I+1:
	P%(NI,I*2-1)=0:
	P%(NI,I*2)=0:
	GOTO 1140
1150 FR%=FR%+1:
	IF FR% > NRC(4) THEN 1190
	ELSE 1110
1190 RETURN
