	REMARK	*****************************************\
		*  P/R140.BAS     PAYROLL CHECK WRITER  *\
		*    5/17/79		11:15 P.M.      *\
		*****************************************
%INCLUDE CURSOR

	DIM MONEY$(39),S(96),R$(5),R1(2),R2(5),G2$(5),G3(5)

	DATA "ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT"	REMARK  DATA TABLE FOR CHECK CALCULATION
	DATA "NINE","TEN","ELEVEN","TWELVE","THIRTEEN","FOURTEEN","FIFTEEN"
	DATA "SIXTEEN","SEVENTEEN","EIGHTEEN","NINETEEN","TWENTY","THIRTY"
	DATA "FORTY","FIFTY","SIXTY","SEVENTY","EIGHTY","NINETY"
	DATA "JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST"
	DATA "SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"
	DEF FNR(Z1)=INT(Z1*100+.5)/100					REMARK  ROUNDING FUNCTION
	RESTORE
	FOR I%=1 TO 39
	READ MONEY$(I%)
	NEXT I%
	GOTO 6000
%INCLUDE SUBS1
%INCLUDE GENINFO
%INCLUDE MSTRIN
5000	X4$=""								REMARK  ROUTINE TO PRINT CHECK AMOUNT IN ENGLISH
	IF A1<0 THEN RETURN						REMARK  IF ZERO CHECK AMOUNT, RETURN
	N1=INT(A1/1000)							REMARK  DIVIDE AMOUNT BY 1000
	IF N1>99 THEN RETURN						REMARK  CHECK CAN BE NO GREATER THAN $99,999.99
	IF N1=0 THEN 5005
	GOSUB 5040							REMARK  CONVERT THOUSANDS OF DOLLARS TO ENGLISH
	X4$=X4$+" THOUSAND"
5005	A1=A1-N1*1000
	N1=INT(A1/100)							REMARK  DIVIDE AMOUNT BY 100
	IF N1=0 THEN 5010
	GOSUB 5040							REMARK  CONVERT HUNDREDS OF DOLLARS TO ENGLISH
	X4$=X4$+" HUNDRED"
5010	A1=A1-N1*100
	N1=INT(A1)							REMARK  REMAINING DOLLARS
	IF N1 > 0 THEN GOSUB 5040
	IF LEN(X4$)=0 THEN 5025
5020	X4$=X4$+" DOLLARS"
5025	A1=A1-N1							REMARK  CALCULATE REMAINING CENTS
	IF A1 < .01 THEN RETURN						REMARK  IF NO CENTS, RETURN
	IF LEN(X4$) > 0 THEN X4$=X4$+" AND"
5030	A1=A1*100
	X4$=X4$+" "+STR$(A1)+" CENTS"
5035	RETURN
5040	IF N1 < 21 THEN X4$=X4$+" "+MONEY$(N1):RETURN			REMARK  CONVERT AMOUNT IN N1 TO ENGLISH IN X4$
	X4$=X4$+" "+MONEY$(INT((N1-20)/10)+20)
	A3=N1-INT(N1/10)*10
	IF A3=0 THEN RETURN
	X4$=X4$+"-"
5050	X4$=X4$+MONEY$(A3)
5055	RETURN
6000	A$="  ###.## #####.## ##.## ####.## #####.## ###.##"		REMARK  SET UP PRINT MASKS FOR CHECK WRITER
	B$=" ##,  ##"
	C$="###.## ###.## ###.## "
	D$="####.## ####.##"
	E$="-####.##"
	Y9=3
	OPEN "P/R0F110.DAT" RECL 1150 AS 1,\
	"P/R0F030.DAT" RECL 38 AS 2,\
	"G/I0F010.DAT" RECL 200 AS 3
	GOSUB 700							REMARK  READ GENERAL INFORMATION FILE
	CONSOLE
	PRINT CLEAR.SCREEN$;"CHECK WRITER"				REMARK DISPLAY PROGRAM I.D.
	PRINT
	PRINT
	PRINT
	PRINT "START EMPLOYEE NUMBER"
	PRINT "END EMPLOYEE NUMBER"
6035	X1=279:X2=3:X3=0:X4=999:GOSUB 345				REMARK  ENTER FIRST EMPLOYEE TO WRITE PAYROLL CHECK FOR
	IF X0=0 THEN 6320						REMARK  END PROGRAM ON ZERO EMPLOYEE NUMBER
	E1=X0
	X1=343:X2=3:X3=E1:X4=999:GOSUB 345				REMARK  ENTER LAST EMPLOYEE NUMBER IN RANGE
	E2=X0
	IF E2 > MSTR.RECORDS THEN E2=MSTR.RECORDS			REMARK  RESET END EMPLOYEE ON DEFAULT ENTRY
	X2=1:X3=0:X4=1:X2$="ENTRY CORRECT?"
	GOSUB 665							REMARK  VERIFY ENTRY: '1'=O.K., '0'=RETRY
	IF X0 <> 1 THEN 6035
	LPRINTER
	FOR I2%=E1 TO E2
	X0=I2%
	GOSUB 745							REMARK  READ MASTER RECORD FOR EMPLOYEE
	IF S(1)=0 OR S(83)=0 OR R2(1)=99 THEN GOTO 6271			REMARK  IF EMPLOYEE RECORD IS DELETED, INACTIVE\
									        OR HAS NOT BEEN PAID, DO NOT WRITE A CHECK.
6100	PRINT TAB(16);R$(1);TAB(61);					REMARK  PRINT EMPLOYEE NAME ON PAY STUB
	X0=G3(2):GOSUB 680.5						REMARK  PRINT PERIOD START DATE ON CHECK
	PRINT " TO ";
	X0=G3(3):GOSUB 680.5						REMARK  PRINT PERIOD END DATE ON CHECK
	PRINT:PRINT
	PRINT USING A$; S(73),S(74),S(75),S(76),S(83),S(85);		REMARK  PRINT REGULAR HOURS, REGULAR PAY,\
									        O/T HOURS, O/T PAY, TOTAL PAY, FED W/H

	PRINT USING C$;S(87),S(88);S(86);				REMARK  PRINT FICA, SDI AND STATE W/H TAXES
	PRINT USING D$; S(89),S(83)-S(90)				REMARK  PRINT OTHER DEDUCTIONS AND NET PAY
	FOR I%=1 TO 7:PRINT:NEXT I%					REMARK  SPACE DOWNWARD TO CHECK AMOUNT AREA
	X0$=RIGHT$("000000"+STR$(G3(1)),6)
	Z1=VAL(LEFT$(X0$,2))						REMARK  Z1=MONTH
	Z2=VAL(MID$(X0$,3,2))						REMARK  Z2=DAY
	Z3=VAL(RIGHT$(X0$,2))						REMARK  Z3=YEAR
	X4$=MONEY$(27+Z1)
	PRINT TAB(69-LEN(X4$));X4$;					REMARK  PRINT MONTH IN ENGLISH
	PRINT USING B$;Z2,Z3
	PRINT
	PRINT
	A1=S(83)-S(90)
	GOSUB 5000							REMARK  CREATE ENGLISH CHECK AMOUNT IN X4$
	PRINT TAB(2); "**";X4$;"**";TAB(65);				REMARK  PRINT CHECK AMOUNT
	PRINT USING "**#####.##";S(83)-S(90)
	FOR I%=1 TO 6:PRINT:NEXT I%					REMARK PRINT LINE FEEDS TO PAYEE SECTION
	PRINT TAB(5);"**";R$(1);"**"					REMARK  PRINT CHECK PAYEE
	FOR I=1 TO 9:PRINT:NEXT I					REMARK  SKIP TO CHECK STUB TO PRINT DEDUCTIONS
6200	IF D1 > S(1) THEN 6270
	READ #2;D1,D2,D3,D4,D1$,D5,D6					REMARK  READ DEDUCTION RECORD
	IF END #2 THEN 6270
	IF D1 < S(1) THEN 6200						REMARK  SEARCH FOR DEDUCTION/MISC PAY FOR EMPLOYEE
	IF D4 < 10 THEN 6200						REMARK  IF RECORD IS UNUSED, GET NEXT
6255	IF D2 < 2 THEN 6260
	X=-1
	D6=D6*X
6260	PRINT TAB(54);D1$;TAB(67);					REMARK  PRINT DESCRIPTION
	PRINT USING E$;D6						REMARK  PRINT AMOUNT ON CHECK STUB
	GOTO 6200
6270	PRINT
	PRINT
	PRINT
6271	NEXT I2%
6320	CONSOLE
	PRINT CLEAR.SCREEN$;"P/R CHECK WRITER LOADING MENU"
	CHAIN "P/R000"
