	REMARK	***********************************************\
		*   P/R070.BAS  TRANS. ACCUMULATE TO SUMMARY  *\
		*    5/14/79                   9:48 AM        *\
		***********************************************
%INCLUDE CURSOR
	DIM T2(8),B1(5)
	DEF FNEXACT(X0,X1,X2)=X0*1000+X1*10+X2
	GOTO 6000
5120	IF END #Y4 THEN 5122
	READ  #Y4;T2(1),T2(2),T2(3),T2(4),T2(5),T2(6),T2(7),T2(8)	REMARK  READ RECORD FROM TRANSACTION FILE
	RETURN
5122	R1=99
	IF R2=99 THEN RETURN						REMARK  IF END OF FILE WAS REACHED ON TRANSACTION FILE,\
									        READ RECORDS FROM THE PAYROLL SUMMARY FILE.
	READ #Y5;T2(1),T2(2),T2(3),T2(7),T2(8)
	R1=0
	RETURN
5130	IF END #Y5 THEN 5132
	READ #Y5;B1(1),B1(2),B1(3),B1(4),B1(5)				REMARK  READ JOB POSTING VARIABLES FROM JOB POSTING FILE
	IF B1(1)=9000000000 THEN B1(1)=0:GOTO 5132			REMARK  IF END OF FILE, SET FLAG
	RETURN
5132	R2=99
	IF R1=99 THEN RETURN
									REMARK  IF END OF FILE REACHED ON P/R SUMMARY FILE,\
									        GET NEXT RECORD FROM THE TRANSACTION FILE.
	READ #Y4;B1(1),B1(2),B1(3),X0,X0,X0,B1(4),B1(5)
	R2=0
	RETURN
5140	IF B1(1)=0 THEN RETURN
	PRINT #Y6;B1(1),B1(2),B1(3),B1(4),B1(5)				REMARK  WRITE TRANSACTION SUMMARY RECORD
	FOR I%=1 TO 5:B1(I%)=0:NEXT I%					REMARK  RE-INITIALIZE TRANSACTION SUMMARY RECORD
	RETURN


6000	PRINT CLEAR.SCREEN$;"P/R TRANSACTION SUMMARY":PRINT
	PRINT "KEY RETURN TO BEGIN; CTRL-C TO EXIT"
6000.1	IF CONSTAT%=0 THEN 6000.1
	A%=CONCHAR%
	IF A% = 03H THEN\
	PRINT CLEAR.SCREEN$;"P/R TRANS. SUMMARY LOADING MENU":\		REMARK  IF CTRL-C WAS PRESSED, LOAD MENU
	CHAIN "P/R000"
	IF A% <> 0DH THEN GOTO 6000.1					REMARK  IF <RETURN> WAS NOT HIT, WAIT FOR KEYSTROKE
	PRINT:PRINT "WORKING...DO NOT INTERRUPT "
	Y4=1
	Y5=2
	Y6=3
	OPEN "P/R0F040.DAT" RECL 42 AS Y4				REMARK  OPEN PAYROLL TRANSACTION FILE
	OPEN "P/R0F050.DAT" RECL 30 AS Y5				REMARK  OPEN P/R TRANSACTION SUMMARY FILE
	CREATE "WORKFILE.DAT" RECL 30 AS Y6				REMARK  CREATE OUTPUT WORK FILE
	GOSUB 5120							REMARK  READ FIRST TRANSACTION RECORD
	GOSUB 5130							REMARK   ""   ""   SUMMARY RECORD
6100	IF R1=99 AND R2=99 THEN 9999					REMARK  IF END OF BOTH FILES, END PROGRAM
6135	IF FNEXACT(B1(1),B1(2),B1(3))=FNEXACT(T2(1),T2(2),T2(3)) THEN\
	B1(4)=B1(4)+T2(7):B1(5)=B1(5)+T2(8):GOSUB 5120:GOTO 6100	REMARK  IF DUPLICATE RECORD, ACCUMULATE HOURS & AMOUNTS
	IF FNEXACT(B1(1),B1(2),B1(3)) < FNEXACT(T2(1),T2(2),T2(3))\
	OR R1=99 THEN GOSUB 5140:GOSUB 5130				REMARK  IF SUMMARY RECORD IS LOWER,\
									        WRITE IT TO WORKFILE
6150	IF FNEXACT(B1(1),B1(2),B1(3)) > FNEXACT(T2(1),T2(2),T2(3)) \
	OR R2=99 THEN\
	PRINT #Y6;T2(1),T2(2),T2(3),T2(7),T2(8):GOSUB 5120		REMARK  IF TRANSACTION RECORD IS LOWER,\
									        WRITE IT OUT TO WORKFILE
	GOTO 6100
9999	IF B1(1)=9000000000 OR T2(1)=9000000000 THEN 9999.5
	GOSUB 5140							REMARK  WRITE LAST TRANSACTION SUMMARY RECORD
	B1(1)=9000000000
	GOSUB 5140							REMARK  WRITE TRAILER RECORD TO SUMMARY FILE
9999.5	CLOSE 1,2,3
	OPEN "P/R0F050.DAT" AS 1
	DELETE 1
	A%=RENAME("P/R0F050.DAT","WORKFILE.DAT")				REMARK  SCRATCH SUMMARY FILE; REPLACE IT WITH WORK FILE
9999.9	PRINT "P/R TRANSACTIONS TRANSFER TO JOB POSTING"
	CHAIN "P/R080"							REMARK  LOAD MENU
