#
###############################################################
# Facts7.rul rule file for standard Facts Accounting Software #
# Based upon Facts 7.0 demo data - 66 line non-preprinted docs#
###############################################################
# This rule file is provided "AS IS", without warranty. #
# Under no circumstances will the publisher be liable   #
# for consequential damages resulting from the use or   #
# inability to use the contents.                        #
#########################################################

# Generic comments ######################################

# See each form below for settings
# -------------------------------------------------------------
# To avoid problems associated with an upgrade overwriting
# this file in the future, you should copy this to a new
# name and reference that name in your printing configuration.
# -------------------------------------------------------------
# Also notice all forms are organized by module code

# Last modified 08/05/2002

# Modification History ###################################
# moved old mod history to bottom of rule file
# 05/14/2002 - bcj
#	Fixed detect problem on P/O VI-type by adding () to !ITEM & ITEM!
# 05/21/2002 - bcj
#	Re-ordered rule sets by priority instead of by module.
#	Recommend moving all unused rule sets to bottom to speed up
#	initial processing of documents
#	Fixed length of location field on P/O fill report
#	Added alternate locations to P/O Fill report
#	Added alternate locations, price, ext to pick slip
#	Added alternate locations to transfer ticket
#	Changed headings to proper case on transfer ticket
# 06/11/2002 - bcj
#	Fixed problem with box around message area on statements
# 06/12/2002 - bcj
#	adjusted rows from 60 to 61 on ar transaction aging
#	added lot # handling to 3 forms
# 07/02/2002 - bcj
#	fixed page length and fonting problems on dunning letter
# 07/26/2002 - bcj
#	added multi-page capabilities to pick slip
# 08/05/2002 - bcj
#	fixed problem with G/L trial balance not allowing for 
#	enough heading lines

# Global constants #######################################

# Adjust the following constants to correct files and info
# if you use the subst file then replace each constant 
# with subst info in rule sets below
const COMP_NAME="Company Name: Edit rule file"
const COMP_ADDR1="Address 1"
const COMP_ADDR2="Address 2"
const COMP_ADDR3="Address 3"
const COMP_PHONES="###-###-####  Fax: ###-###-####"
const COMP_EMAIL="E-Mail: xxxx@xxxxxxxxxxxxxxx.com"
const COMP_WEBSITE="Website: www.xxxxxxxxxxxxxxx.com"

# Bank info for AP checks
const AP_BANK_NAME="One Major Bank"
const AP_BANK_ADDR1="1 Major Blvd"
const AP_BANK_ADDR2="Major City CA 90123"
const AP_ROUTING="12-345/6789"

# How many AP check stubs are required.
const AP_NO_STUBS=2	# 1=vendor stub, 
				# 2=vendor stub and payor stub

# MICR code on AP checks, 
const AP_MICR_ACCOUNTNO=":123456789:9999-1234<34>"
const AP_MICR="micr"

# Bank information for PR checks
const PR_BANK_NAME="One Major Bank"
const PR_BANK_ADDR1="1 Major Blvd"
const PR_BANK_ADDR2="Major City CA 90123"
const PR_ROUTING="12-345/6789"

# How many PR check stubs are required.
const PR_NO_STUBS=2	# 1=employee stub, 
				# 2=employee stub and employer stub

# MICR code on PR checks, 
const PR_MICR_ACCOUNTNO=":123456789:9999-1234<34>"
const PR_MICR="micr"

# check signature on AP/PR checks,
const SIGNATURE_IMAGE="#image" 
const SIGNATURE=""

#####################################
# in the following constants, a # in front of the constant 
# will effectively remove the command from
# all applicable rule sets, while no # will make the command active
# eg. The following would make signature active
#	const SIGNATURE_IMAGE="image"
# eg. The following would make signature inactive
#	const SIGNATURE_IMAGE="#image" 
#####################################

# Logos
const LOGO_IMAGE="image"
const COMP_LOGO="sdsilogo.pcl"

# for faster processing, place a # in front of the constants below
# eg. Change const SO_INV_CFONT="cfont" to 
#		 const SO_INV_CFONT="#cfont"
# for more professional looking documents remove the #
# eg. Change const SO_INV_CFONT="#cfont" to 
#		 const SO_INV_CFONT="cfont"
const AR_INV_CFONT	="cfont"
const AR_STMT_FONT	="font"
const AR_STMT_CFONT	="cfont"
const JC_EST_CFONT	="cfont"
const JC_INV_CFONT	="cfont"
const PO_CFONT		="cfont"
const PO_FONT		="font"
const SO_BOL_CFONT	="cfont"
const SO_INV_CFONT	="cfont"
const SO_INV_FONT		="font"
const SO_PICK_CFONT	="cfont"
const SO_PICK_FONT	="font"
const SO_QUOTE_FONT	="font"
const SO_QUOTE_CFONT	="cfont"

# What justification for ITEM column header
const ITEM_JUSTIFY="right"

# date mask for detects - 10/17/01
const DATEMASK="[0-1][0-9]/[0-3][0-9]/[0-9][0-9]"	# US dt
#const DATEMASK="[0-3][0-9]/[0-1][0-9]/[0-9][0-9]"	# Can dt

# BBx uses fill command, PVx uses dim command
const FILL_CMD=fill						# BBx
#const FILL_CMD=dim						# PVx

# main heading constants
const HFONT=  univers,10
const HRFONT= univers,10,right
const HCFONT= univers,10,center
const HSHADE= 20
# bold
const HBFONT= univers,10,bold
const HBRFONT=univers,10,right,bold
const HBCFONT=univers,10,center,bold

# internal heading font constants (ribbons, detail headers)
const IFONT=  univers,8,italic
const ICFONT= univers,8,italic,center
const IPFONT= univers,8,italic,decimal
const IRFONT= univers,8,italic,right
const ISHADE= 15
# bold
const IBFONT= univers,8,italic,bold
const IBCFONT=univers,8,italic,center,bold
const IBPFONT=univers,8,italic,decimal,bold
const IBRFONT=univers,8,italic,right,bold

# detail data font constants
const DFONT=  cgtimes,9
const DCFONT= cgtimes,9,center
const DPFONT= cgtimes,9,decimal
const DRFONT= cgtimes,9,right
const DSHADE= 10
# bold
const DBFONT= cgtimes,9,bold
const DBCFONT=cgtimes,9,center,bold
const DBPFONT=cgtimes,9,decimal,bold
const DBRFONT=cgtimes,9,right,bold
# detail data font constants for wide forms
const DSFONT=  cgtimes,8
const DSCFONT= cgtimes,8,center
const DSPFONT= cgtimes,8,decimal
const DSRFONT= cgtimes,8,right
# bold
const DSBFONT= cgtimes,8,bold
const DSBCFONT=cgtimes,8,center,bold
const DSBPFONT=cgtimes,8,decimal,bold
const DSBRFONT=cgtimes,8,right,bold

# default major section box size
const MBOXSIZE=5

#***************************************************************
#                 Most frequently used rule sets               *
#***************************************************************

[S/O Invoice - Long form]
# Invoice Control	1-66, 2-N, 3-L, 4-1/2/B
detect 0,2,"~(INVOICE)|(CREDIT MEMO)|(RETURN GOODS)"
detect 0,16,"~(SALESPERSON)|(Salesperson)"

# document options
const MAXCOLS=100
const MAXRCOLS=99
const LEFTCOL=1
const MAXROWS=66
cols MAXCOLS
page MAXROWS
rows MAXROWS

const CUSTOMER_COPY=1
const FILE_COPY=2
pcopies 2


prepage {
	#get header info for better placement
	title$=trim(get(25,2,40))
	if title$(1,6)="RETURN" then \
		title$="RETURN GOODS"
	# get comp info from page or constants?
	compname$=trim(get(20,3,46))
	if compname$="" then \
			compname$="COMP_NAME"; \
			addr1$="COMP_ADDR1"; \
			addr2$="COMP_ADDR2"; \
			addr3$="COMP_ADDR3"; \
			phone$="Phone: COMP_PHONES" \
		else \
			addr1$=trim(get(20,4,46)); \
			addr2$=trim(get(20,5,46)); \
			addr3$=trim(get(20,6,46)); \
			phone$=trim(get(20,7,46)); \
			if phone$="" then if addr3$="" or \
					addr3$(1,1)>="A" then \
					phone$="Phone: COMP_PHONES" \
				else \
					phone$="Phone: "+addr3$,addr3$="" \
				else 	phone$="Phone: "+phone$
	if addr3$="" then addr3$=phone$,phone$=""

	invno$=trim(get(93,3,6))
	invpage$=trim(get(96,5,3))
	invdate$=trim(get(91,7,8))
	if invdate$="" then invdate$=trim(get(18,18,8))
	cust_code$=trim(get(16,10,25))
	x=pos("Ship-to:"=text$[10])
	shipto_code$=trim(get(x+8,10,15))

	# search for bottom of vertical lines in detail area
	# prepayment area should not have any vertical lines
	# detail lines will have many !, prepayment only 2 !
	desc_pos=pos("DESCRIPTION"=text$[20])
	if desc_pos=0 then desc_pos=pos("Description"=text$[20])
	detail_bottom=60
	equal$=FILL_CMD(98,"=")
	for i=22 to detail_bottom-1
		if pos(equal$=text$[i])=2 then \
			detail_bottom=i;break
		x=pos("!"=text$[i],1,0)		# get # of !
		if x=2 then detail_bottom=i-1; break
	next i

	if detail_bottom<=22 then goto draw_no_detail_lines
	x$=set(1,detail_bottom,100,"")
	if detail_bottom<60 then \
		x$="cbox LEFTCOL,21,MAXCOLS,"+str(detail_bottom)
		exec(x$)
	# draw vertical lines
	x$="cbox "+str(desc_pos-1)+",19,"+str(desc_pos-1)+","+ \
			str(detail_bottom)
	exec(x$)
	x$="cbox 43,19,43,"+str(detail_bottom)
	exec(x$)
	x$="cbox 53,19,63,"+str(detail_bottom)
	exec(x$)
	x$="cbox 73,19,76,"+str(detail_bottom)
	exec(x$)
	x$="cbox 86,19,89,"+str(detail_bottom)
	exec(x$)
draw_no_detail_lines:

	# find memo lines and mark them for enhancing later
	if detail_bottom<=21 then goto no_memo_lines
	serial_on=0
	for i=22 to detail_bottom-1
		# if ! exists: remove it
		if text$[i](desc_pos-1,1)="!" then \
			text$[i](desc_pos-1,1)=" "
		if text$[i](43,1)="!" then text$[i](43,1)=" "
		if text$[i](53,1)="!" then text$[i](53,1)=" "
		if text$[i](63,1)="!" then text$[i](63,1)=" "
		if text$[i](73,1)="!" then text$[i](73,1)=" "
		if text$[i](76,1)="!" then text$[i](76,1)=" "
		if text$[i](86,1)="!" then text$[i](86,1)=" "
		if text$[i](89,1)="!" then text$[i](89,1)=" "
		# if item # exists; must be item line
		if trim(text$[i](2,desc_pos-3))<>"" then \
			serial_on=0;continue
		# is it a blank line?
		if trim(text$[i](desc_pos,20))="" then continue
		# is it a serial # line
		if text$[i](desc_pos,5)="Ser# " or \
			text$[i](desc_pos,5)="Lot# " then \
			text$[i](desc_pos-3,2)="sL"; \
			serial_on=1; continue
		if text$[i](desc_pos,5)="     " and serial_on then \
			text$[i](desc_pos-3,2)="sL"; \
			continue
		# must be memo line or 2nd desc line
		text$[i](desc_pos-3,2)="mL"; serial_on=0
	next i
no_memo_lines:

	# mark prepayment lines for later enhancing
	if detail_bottom>=60 then goto no_prepayment_lines
	for i=detail_bottom+1 to 59
		if pos("-----"=text$[i]) then text$[i]=""; \
			exec("cbox 15,"+str(i)+",42,"+str(i));continue
		if text$[i](15,1)<>"" then text$[i](13,2)="pL"
	next i
no_prepayment_lines:

}

# erase columns !
cerase 1,1,1,MAXROWS
cerase 100,1,100,MAXROWS

# erase rows - or =
cerase 1,1,100,1
cerase 1,15,100,15
cerase 1,17,100,17
cerase 1,19,100,19
cerase 1,21,100,21
cerase 1,60,100,60
cerase 1,MAXROWS,100,MAXROWS
hline "^^"

# header
cerase 1,1,100,10
cbox LEFTCOL,1,MAXCOLS,MAXROWS,MBOXSIZE
cbox LEFTCOL,1,MAXCOLS,10,MBOXSIZE
LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
text 1,2,{title$},HBRFONT,16,cols=MAXRCOLS
text 1,2,{compname$},HBCFONT,14,cols=MAXRCOLS
text 1,3.2,{addr1$},HCFONT,12,cols=MAXRCOLS
text 1,4.3,{addr2$},HCFONT,12,cols=MAXRCOLS
text 1,5.4,{addr3$},HCFONT,12,cols=MAXRCOLS
text 1,6.5,{phone$},HCFONT,12,cols=MAXRCOLS
text 1,7.5,"COMP_EMAIL",HCFONT,cols=MAXRCOLS
text 1,8.5,"COMP_WEBSITE",HCFONT,cols=MAXRCOLS
if copy CUSTOMER_COPY
	text 81,4.5,"Customer Copy",HBCFONT,12,cols=19,shade 0
end if
if copy FILE_COPY
	text 81,4.5,"File Copy",HBCFONT,12,cols=19,shade 0
end if

# right header
cbox 80,3.75,MAXCOLS,5.25,1,100
cbox 80,5.5,MAXCOLS,10
cbox 80,5.5,90,10,1,ISHADE
cbox 80,7,MAXCOLS,8.5
text 82,6.25,"Number",IFONT
text 82,7.75,"Date",IFONT
text 82,9.25,"Page",IFONT
text 92,6.25,{invno$},DSBFONT
text 92,7.75,{invdate$},DSBFONT
text 92,9.25,{invpage$},DSBFONT

# bill to section
cbox LEFTCOL,10,MAXCOLS,15,MBOXSIZE
cbox LEFTCOL,10,13,15,1,ISHADE
text 2,11,"Bill To:",IFONT
text 2,12,{cust_code$},DSBFONT
cmove 7,11,45,14,14,11
cfont 14,11,45,14,DSBFONT				# bill to addr

# ship to section
cbox 51,10,63,15,1,ISHADE
text 52,11,"Ship To:",IFONT
text 52,12,{shipto_code$},DSBFONT
cmove 62,11,MAXRCOLS,14,64,11
cfont 64,11,MAXCOLS,14,DSBFONT			# ship to addr

# ribbon section
cerase 17,15,17,19
cerase 26,15,26,19
cerase 41,15,41,19
cerase 57,15,57,19
cerase 66,15,66,19
cerase 73,15,73,19
cerase 76,15,76,19
cerase 84,15,84,19
cbox LEFTCOL,15,MAXCOLS,19,MBOXSIZE
cbox LEFTCOL,15,MAXCOLS,17,1,ISHADE
cbox 17,15,26,19
cbox 41,15,57,19
cbox 66,15,73,19
cbox 76,15,84,19
cfont 2,16,16,16,IFONT					# ref #
cfont 18,16,25,16,ICFONT				# shipped dt
cfont 27,16,40,16,ICFONT				# salesperson
cfont 42,16,56,16,IFONT					# terms
cfont 58,16,65,16,IFONT					# tax code
cfont 67,16,72,16,IFONT					# doc #
cfont 74,16,75,16,ICFONT				# whs
cfont 77,16,83,16,ICFONT				# frt
cfont 85,16,MAXRCOLS,16,IFONT				# ship via

cfont 2,18,16,18,DSBFONT				# ref #
cfont 18,18,25,18,DSBCFONT				# shipped dt
cfont 27,18,40,18,DSBCFONT				# salesperson
cfont 42,18,56,18,DSBFONT				# terms
cfont 58,18,65,18,DSBFONT				# tax code
cfont 67,18,72,18,DSBFONT				# doc #
cfont 74,18,75,18,DSBCFONT				# whs
cfont 77,18,83,18,DSBCFONT				# frt
cfont 85,18,MAXRCOLS,18,DSBFONT			# ship via

# detail
const XMASK="DESCRIPTION@2,20,40,20"
const X1MASK="Description@2,20,40,20"
erase "XMASK",-1,0,1,1
erase "X1MASK",-1,0,1,1
cerase 43,20,43,20
cerase 53,20,53,20
cerase 63,20,63,20
cerase 73,20,73,20
cerase 76,20,76,20
cerase 86,20,86,20
cerase 89,20,89,20
cbox LEFTCOL,19,MAXCOLS,60,MBOXSIZE
cbox LEFTCOL,19,MAXCOLS,21,1,DSHADE
cfont "XMASK",-2,0,2,20,IFONT,ITEM_JUSTIFY	# code
cfont "X1MASK",-2,0,2,20,IFONT,ITEM_JUSTIFY	# code
cfont "XMASK",0,0,43,20,IFONT				# desc
cfont "X1MASK",0,0,43,20,IFONT			# desc
cfont 44,20,52,20,IRFONT				# ordered
cfont 54,20,62,20,IRFONT				# shipped
cfont 64,20,72,20,IRFONT				# backordered
cfont 74,20,75,20,ICFONT				# uom
cfont 77,20,85,20,IRFONT				# price
cfont 87,20,88,20,ICFONT				# uom
cfont 90,20,MAXRCOLS,20,ICFONT			# extension

const XMASK="DESCRIPTION@2,20,40,20"
const X1MASK="Description@2,20,40,20"
SO_INV_CFONT "XMASK",-2,2,2,60,DSBFONT,ITEM_JUSTIFY	# item
SO_INV_CFONT "X1MASK",-2,2,2,60,DSBFONT,ITEM_JUSTIFY	# item
SO_INV_CFONT "XMASK",0,2,43,60,DSFONT		# desc
SO_INV_CFONT "X1MASK",0,2,43,60,DSFONT		# desc
SO_INV_CFONT 44,22,52,60,DSBRFONT			# ordered
SO_INV_CFONT 54,22,62,60,DSBRFONT			# shipped
SO_INV_CFONT 64,22,72,60,DSBRFONT			# backordered
SO_INV_CFONT 74,22,75,60,DSBCFONT			# uom
SO_INV_CFONT 77,22,85,60,DSBRFONT			# price
SO_INV_CFONT 87,22,88,60,DSBCFONT			# uom
SO_INV_CFONT 90,22,MAXRCOLS,60,DSBPFONT		# extension
# handle memo lines
SO_INV_FONT "mL@2,22,25,59",3,0,40,1,DSFONT	# memo lines
erase "mL@2,22,40,59",0,0,2,1				# spec chars
# enhance serial # lines
SO_INV_FONT "sL@2,22,25,59",3,0,4,1,DSFONT	# serial lines
SO_INV_FONT "sL@2,22,25,59",8,0,40,1,DSFONT	# serial lines
erase "sL@2,22,40,59",0,0,2,1				# spec chars
# handle payment info
SO_INV_FONT "pL@2,22,40,59",2,0,15,1,DSFONT	# pymt desc
SO_INV_FONT "pL@2,22,40,59",17,0,13,1,DSBPFONT	# pymt amts
SO_INV_FONT "pL@2,22,40,59",30,0,40,1,DSFONT	# pymt comment
erase "pL@2,22,40,59",0,0,2,1				# spec chars

# footer
cerase 32,62,100,62
cerase 32,64,100,64
cerase 32,61,32,63
cerase 44,61,44,63
cerase 56,61,56,63
cerase 68,61,68,63
cerase 78,61,78,63
cerase 87,61,87,63
cbox LEFTCOL,60,MAXCOLS,MAXROWS,MBOXSIZE
cbox 31,60,MAXCOLS,62,1,HSHADE
cbox 31,62,MAXCOLS,64
cbox 44,60,56,64
cbox 68,60,78,64
cbox 87,60,87,64
cfont 32,61,43,61,IBRFONT			# merchandise
cfont 45,61,55,61,IBRFONT			# misc
cfont 57,61,67,61,IBRFONT			# discount
cfont 69,61,77,61,IBRFONT			# tax
cfont 79,61,86,61,IBRFONT			# frt
cfont 88,61,MAXRCOLS,61,IBRFONT,9		# tot due

cfont 32,63,43,63,DSBRFONT			# merchandise
cfont 45,63,55,63,DSBRFONT			# misc
cfont 57,63,67,63,DSBRFONT			# discount
cfont 69,63,77,63,DSBRFONT			# tax
cfont 79,63,86,63,DSBRFONT			# frt
cfont 88,63,MAXRCOLS,63,DSBRFONT,10		# tot due

cfont 2,61,31,64,DSFONT
cfont 2,65,MAXCOLS,65,DSFONT

[S/O Pick Ticket]
# Pick Control	1-66, 2-N, 3-1/2/B
detect 0,2,"PICK TICKET"
detect 0,16,"SLSP"

# document options
const MAXCOLS=85
const MAXRCOLS=84
const LEFTCOL=1
const MAXROWS=66
cols MAXCOLS
page MAXROWS
rows MAXROWS

const CUSTOMER_COPY=1
const FILE_COPY=2
pcopies 2

prepage {
	#get header info for better placement
	title$=trim(get(35,2,11))
	invreprint$=trim(get(77,2,7))
	# get comp info from page or constants?
	compname$=trim(get(20,3,40))
	if compname$="" then \
			compname$="COMP_NAME"; \
			addr1$="COMP_ADDR1"; \
			addr2$="COMP_ADDR2"; \
			addr3$="COMP_ADDR3"; \
			phone$="Phone: COMP_PHONES" \
		else \
			addr1$=trim(get(20,4,46)); \
			addr2$=trim(get(20,5,46)); \
			addr3$=trim(get(20,6,46)); \
			phone$=trim(get(20,7,46)); \
			if phone$="" then if addr3$="" or \
					addr3$(1,1)>="A" then \
					phone$="Phone: COMP_PHONES" \
				else \
					phone$="Phone: "+addr3$,addr3$="" \
				else 	phone$="Phone: "+phone$
	if addr3$="" then addr3$=phone$,phone$=""

	invno$=trim(get(78,3,6))
	invpage$=trim(get(82,5,3))
	invdate$=trim(get(76,7,8))
	cust_code$=trim(get(62,10,20))
	shipto_code$=trim(get(15,10,15))

	# find/mark memo lines
	desc_pos=pos("DESCRIPTION"=text$[20])
	for i=22 to 62
		if trim(text$[i](2,desc_pos-3))="" then \
			text$[i](desc_pos-3,2)="mL"
	next i

}

# erase vertical & horizontal lines
vline "!!",erase
hline "--",erase
hline "==",erase

# default line enhancements
const XMASK=DESCRIPTION@2,20,40,20
SO_PICK_CFONT "XMASK",-2,2,2,62,DBFONT,ITEM_JUSTIFY # item
SO_PICK_CFONT "XMASK",0,2,42,62,DFONT		# desc
SO_PICK_CFONT 44,22,52,62,DBRFONT			# committed
SO_PICK_CFONT 54,22,59,62,DBRFONT			# shipped
SO_PICK_CFONT 61,22,65,62,DBRFONT			# backordered
SO_PICK_CFONT 67,22,68,62,DBCFONT			# uom
SO_PICK_CFONT 70,22,77,62,DBRFONT			# wt
SO_PICK_CFONT 79,22,MAXRCOLS,62,DSBRFONT		# location

# header
cerase 1,1,MAXCOLS,10
cbox LEFTCOL,1,MAXCOLS,MAXROWS,MBOXSIZE
cbox LEFTCOL,1,MAXCOLS,10,MBOXSIZE
LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
text 1,2,{title$},HBRFONT,16,cols=MAXRCOLS
text 1,3.2,{invreprint$},HRFONT,12,cols=MAXRCOLS
text 1,2,{compname$},HBCFONT,14,cols=MAXRCOLS
text 1,3.2,{addr1$},HCFONT,12,cols=MAXRCOLS
text 1,4.3,{addr2$},HCFONT,12,cols=MAXRCOLS
text 1,5.4,{addr3$},HCFONT,12,cols=MAXRCOLS
text 1,6.5,{phone$},HCFONT,12,cols=MAXRCOLS
text 1,7.5,"COMP_EMAIL",HCFONT,cols=MAXRCOLS
text 1,8.5,"COMP_WEBSITE",HCFONT,cols=MAXRCOLS
if copy CUSTOMER_COPY
	text 70,4.5,"Customer Copy",HBCFONT,12,cols=16,shade 0
end if
if copy FILE_COPY
	text 70,4.5,"File Copy",HBCFONT,12,cols=16,shade 0
end if

# right header
cbox 70,3.75,MAXCOLS,5.25,1,100
cbox 70,5.5,MAXCOLS,10
cbox 70,5.5,77,10,1,ISHADE
cbox 70,5.5,MAXCOLS,7
cbox 70,8.5,MAXCOLS,8.5
text 71,6.25,"Number",IFONT
text 71,7.75,"Date",IFONT
text 71,9.25,"Page",IFONT
text 78,6.25,{invno$},DBFONT
text 78,7.75,{invdate$},DBFONT
text 78,9.25,{invpage$},DBFONT

# ship to section
cbox LEFTCOL,10,MAXCOLS,15,MBOXSIZE
cbox LEFTCOL,10,11,15,1,ISHADE
text 2,11,"Ship To:",IFONT
text 2,12,{shipto_code$},DSBFONT
cmove 7,11,41,14,12,11
cfont 12,11,41,14,DBFONT				# ship to addr

# bill to section
cbox 42,10,52,15,1,ISHADE
text 43,11,"Bill To:",IFONT
text 43,12,{cust_code$},DSBFONT
cfont 53,11,MAXCOLS,14,DBFONT				# bill to addr

# ribbon 1 section
cerase 17,15,17,19
cerase 26,15,26,19
cerase 36,15,36,19
cerase 41,15,41,19
cerase 57,15,57,19
cerase 61,15,61,19
cerase 69,15,69,19
cbox LEFTCOL,15,MAXCOLS,19,MBOXSIZE
cbox LEFTCOL,15,MAXCOLS,17,1,ISHADE
cbox 17,15,26,19
cbox 36,15,41,19
cbox 57,15,61,19
cbox 69,15,69,19
cfont 2,16,16,16,IFONT				# ref #
cfont 18,16,25,16,ICFONT			# ordered
cfont 27,16,35,16,ICFONT			# requested
cfont 37,16,40,16,ICFONT			# salesperson
cfont 42,16,56,16,IFONT				# terms
cfont 58,16,60,16,ICFONT			# whs
cfont 62,16,68,16,IFONT				# frt
cfont 70,16,MAXRCOLS,16,IFONT			# ship via

cfont 2,18,16,18,DBFONT				# ref #
cfont 18,18,25,18,DBCFONT			# ordered
cfont 27,18,35,18,DBCFONT			# requested
cfont 37,18,40,18,DBCFONT			# salesperson
cfont 42,18,56,18,DBFONT			# terms
cfont 58,18,60,18,DBCFONT			# whs
cfont 62,18,68,18,DBFONT			# frt
cfont 70,18,MAXRCOLS,18,DBFONT		# ship via

# detail heading
erase "!@6,20,22,20",0,0,1,1
erase "!@43,19,43,62",0,0,1,1
erase "!@53,19,53,62",0,0,1,1
erase "!@60,19,60,62",0,0,1,1
erase "!@66,19,66,62",0,0,1,1
erase "!@69,19,69,62",0,0,1,1
erase "!@78,19,78,62",0,0,1,1
cbox LEFTCOL,19,MAXCOLS,62,MBOXSIZE
cbox LEFTCOL,19,MAXCOLS,21,1,DSHADE
box "XMASK",-1,-1,1,43
cbox 43,19,43,62
cbox 53,19,60,62
cbox 66,19,69,62
cbox 78,19,MAXCOLS,62

cfont "XMASK",-2,0,2,20,IFONT,ITEM_JUSTIFY	# item
cfont "XMASK",0,0,43,20,IFONT				# desc
cfont 44,20,52,20,IRFONT				# committed
cfont 54,20,59,20,IRFONT				# shipped
cfont 61,20,65,20,IRFONT				# backordered
cfont 67,20,68,20,ICFONT				# uom
cfont 70,20,77,20,IRFONT				# wt
cfont 79,20,MAXRCOLS,20,IRFONT			# location

# handle memo lines
SO_PICK_FONT "mL@2,22,25,62",3,0,30,1,DFONT	# memo lines
erase "mL@2,22,40,62",0,0,2,1				# spec chars

# handle alternate location lines
SO_PICK_FONT "Alt Loc: ",0,0,8,1,DFONT		# title
SO_PICK_FONT "Alt Loc: ",9,0,50,1,DSBFONT		# alt locs

# handle price lines
SO_PICK_FONT "Price: ",0,0,6,1,DFONT		# title
SO_PICK_FONT "Price: ",7,0,9,1,DBRFONT		# price
SO_PICK_FONT "Price: ",17,0,5,1,DBFONT		# uom

# handle price lines
SO_PICK_FONT "Ext: ",0,0,4,1,DFONT			# title
SO_PICK_FONT "Ext: ",5,0,11,1,DBRFONT		# ext price

# footer
cbox LEFTCOL,62,MAXCOLS,MAXROWS,MBOXSIZE
cbox "TOTAL WEIGHT",-2,-1,69,64,1,HSHADE
cbox "TOTAL WEIGHT",14,-1,78,64
cfont 54,63,67,63,IBRFONT,10				# wt
cfont 69,63,77,63,DBRFONT,10				# wt
font "CONTINUED@75,63,83,63",0,0,10,1,IRFONT

cfont 2,63,52,63,IFONT
font "EXTENSION TOT: ",0,0,14,1,IFONT		# title
font "EXTENSION TOT: ",15,0,12,1,DBFONT,10	# ext total
font "EXTENSION TOT: ",28,0,20,1,IFONT
cfont 2,64,MAXRCOLS,64,IFONT

[S/O Invoice - Gross margin/Short Form/RGA/SR Invoice]
# Invoice Control	1-66, 2-N, 3-G/S, 4-1/2/B
# S/R Document Control	13-66, 14-N, 15-S/L, 16-1/2/B, 18-D/S/T
detect 0,2,"~(INVOICE)|(CREDIT MEMO)|(RETURN GOODS)"
detect 0,16,"~(SHIPPED)|(Returned)"
detect 0,16,"~(SLS)|(Sls)"

# document options
const MAXCOLS=81
const MAXRCOLS=80
const LEFTCOL=1
const MAXROWS=66
cols MAXCOLS
page MAXROWS
rows MAXROWS

const CUSTOMER_COPY=1
const FILE_COPY=2
const INTERNAL_COPY=3
pcopies 3

prepage {
	#get header info for better placement
	title$=trim(get(25,2,30))
	if title$(1,6)="RETURN" then \
		title$="RETURN GOODS"
	# get comp info from page or constants?
	compname$=trim(get(20,3,40))
	if compname$="" then \
			compname$="COMP_NAME"; \
			addr1$="COMP_ADDR1"; \
			addr2$="COMP_ADDR2"; \
			addr3$="COMP_ADDR3"; \
			phone$="Phone: COMP_PHONES" \
		else \
			addr1$=trim(get(20,4,46)); \
			addr2$=trim(get(20,5,46)); \
			addr3$=trim(get(20,6,46)); \
			phone$=trim(get(20,7,46)); \
			if phone$="" then if addr3$="" or \
					addr3$(1,1)>="A" then \
					phone$="Phone: COMP_PHONES" \
				else \
					phone$="Phone: "+addr3$,addr3$="" \
				else 	phone$="Phone: "+phone$
	if addr3$="" then addr3$=phone$,phone$=""

	invno$=trim(get(74,3,6))
	invpage$=trim(get(78,5,3))
	invdate$=trim(get(72,7,8))
	if invdate$="" then invdate$=trim(get(18,18,8))
	cust_code$=trim(get(16,10,25))
	shipto_code$=trim(get(58,10,15))

	# search for bottom of vertical lines in detail area
	# prepayment area should not have any vertical lines
	# detail lines will have many !, prepayment only 2 !
	desc_pos=pos("DESCRIPTION"=text$[20])
	if desc_pos=0 then desc_pos=pos("Description"=text$[20])
	detail_bottom=60
	equal$=FILL_CMD(78,"=")
	for i=22 to detail_bottom-1
		if pos(equal$=text$[i])=2 then \
			detail_bottom=i;break
		x=pos("!"=text$[i],1,0)		# get # of !
		if x=2 then detail_bottom=i-1; break
	next i

	# find memo lines and mark them for enhancing later
	if detail_bottom<=21 then goto no_memo_lines
	serial_on=0
	for i=22 to detail_bottom-1
		# if ! exists: remove it
		if text$[i](desc_pos-1,1)="!" then \
			text$[i](desc_pos-1,1)=" "
		if text$[i](43,1)="!" then text$[i](43,1)=" "
		if text$[i](53,1)="!" then text$[i](53,1)=" "
		if text$[i](56,1)="!" then text$[i](56,1)=" "
		if text$[i](66,1)="!" then text$[i](66,1)=" "
		if text$[i](69,1)="!" then text$[i](69,1)=" "
		# if item # exists; must be item line
		if trim(text$[i](2,desc_pos-3))<>"" then \
			serial_on=0;continue
		# is it a blank line?
		if trim(text$[i](desc_pos,20))="" then continue
		# is it a serial # line
		if text$[i](desc_pos,5)="Ser# " or \
			text$[i](desc_pos,5)="Lot# " then \
			text$[i](desc_pos-3,2)="sL"; \
			serial_on=1; continue
		if text$[i](desc_pos,5)="     " and serial_on then \
			text$[i](desc_pos-3,2)="sL"; \
			continue
		# must be memo line or 2nd desc line
		text$[i](desc_pos-3,2)="mL"; serial_on=0
	next i
no_memo_lines:

	# mark prepayment lines for later enhancing
	if detail_bottom>=60 then goto no_prepayment_lines
	for i=detail_bottom+1 to 59
		if pos("-----"=text$[i]) then text$[i]=""; \
			exec("cbox 15,"+str(i)+",42,"+str(i));continue
		if text$[i](15,1)<>"" then text$[i](13,2)="pL"
	next i
no_prepayment_lines:
}

precopy {
	if copy=INTERNAL_COPY then cols$="100"
	if trim(get(86,3,3))<>"NO." and copy=INTERNAL_COPY then \
		skip=1

	if detail_bottom<=22 then goto draw_no_detail_lines
	x$=set(1,detail_bottom,100,"")
	if detail_bottom<60 then \
		x$="cbox LEFTCOL,21,MAXCOLS,"+str(detail_bottom)
		exec(x$)
	# draw vertical lines
	x$="cbox "+str(desc_pos-1)+",19,"+str(desc_pos-1)+","+ \
		str(detail_bottom)
	exec(x$)
	x$="cbox 43,19,43,"+str(detail_bottom)
	exec(x$)
	x$="cbox 53,19,56,"+str(detail_bottom)
	exec(x$)
	x$="cbox 66,19,69,"+str(detail_bottom)
	exec(x$)
draw_no_detail_lines:
}

# erase columns !
cerase 1,1,1,MAXROWS
cerase 81,1,82,MAXROWS
cerase 100,1,100,MAXROWS

# erase rows - or =
cerase 1,1,100,1
cerase 1,15,100,15
cerase 1,17,100,17
cerase 1,19,100,19
cerase 1,21,100,21
cerase 1,60,100,60
cerase 1,MAXROWS,100,MAXROWS
hline "^^"

# erase cost section if not copy 3
if copy CUSTOMER_COPY,FILE_COPY
	cerase 81,1,100,MAXROWS
end if

# header
cerase 1,1,100,10
cbox LEFTCOL,1,MAXCOLS,MAXROWS,MBOXSIZE
cbox LEFTCOL,1,MAXCOLS,10,MBOXSIZE
if copy INTERNAL_COPY
	cbox 82,1,100,MAXROWS,MBOXSIZE
end if
LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
text 1,2,{title$},HBRFONT,16,cols=MAXRCOLS
text 1,2,{compname$},HBCFONT,14,cols=MAXRCOLS
text 1,3.2,{addr1$},HCFONT,12,cols=MAXRCOLS
text 1,4.3,{addr2$},HCFONT,12,cols=MAXRCOLS
text 1,5.4,{addr3$},HCFONT,12,cols=MAXRCOLS
text 1,6.5,{phone$},HCFONT,12,cols=MAXRCOLS
text 1,7.5,"COMP_EMAIL",HCFONT,cols=MAXRCOLS
text 1,8.5,"COMP_WEBSITE",HCFONT,cols=MAXRCOLS
if copy CUSTOMER_COPY
	text 65,4.5,"Customer Copy",HBCFONT,12,cols=16,shade 0
end if
if copy FILE_COPY
	text 65,4.5,"File Copy",HBCFONT,12,cols=16,shade 0
end if
if copy INTERNAL_COPY
	text 65,4.5,"Internal Copy",HBCFONT,12,cols=16,shade 0
end if

# right header
cbox 64,3.75,MAXCOLS,5.25,1,100
cbox 64,5.5,MAXCOLS,10
cbox 64,5.5,72,10,1,ISHADE
cbox 64,7,MAXCOLS,8.5
text 65,6.25,"Number",IFONT
text 65,7.75,"Date",IFONT
text 65,9.25,"Page",IFONT
if copy CUSTOMER_COPY,FILE_COPY
	text 73,6.25,{invno$},DBFONT
	text 73,7.75,{invdate$},DBFONT
	text 73,9.25,{invpage$},DBFONT
end if
if copy INTERNAL_COPY
	text 73,6.25,{invno$},DSBFONT
	text 73,7.75,{invdate$},DSBFONT
	text 73,9.25,{invpage$},DSBFONT
	cbox 82,1,100,8
	cbox 82,1,90,8,1,ISHADE
	cbox 82,4,100,6
	text 83,3,"Number",IFONT
	text 83,5,"Page",IFONT
	text 83,7,"Date",IFONT
	text 91,3,{invno$},DBFONT
	text 91,5,{invpage$},DBFONT
	text 91,7,{invdate$},DBFONT
end if

# bill to section
cbox LEFTCOL,10,MAXCOLS,15,MBOXSIZE
cbox LEFTCOL,10,10,15,1,ISHADE
text 2,11,"Bill To:",IFONT
cmove 8,11,41,14,11,11
if copy CUSTOMER_COPY,FILE_COPY
	text 2,12,{cust_code$},DSBFONT
	cfont 11,11,40,14,DBFONT			# bill to addr
end if
if copy INTERNAL_COPY
	text 2,12,{cust_code$},DSBFONT,7
	cfont 11,11,40,14,DSBFONT			# bill to addr
end if

# ship to section
cbox 41,10,50,15,1,ISHADE
text 42,11,"Ship To:",IFONT
cmove 50,11,79,14,51,11
if copy CUSTOMER_COPY,FILE_COPY
	text 42,12,{shipto_code$},DSBFONT
	cfont 51,11,MAXCOLS,14,DBFONT			# ship to addr
end if
if copy INTERNAL_COPY
	text 42,12,{shipto_code$},DSBFONT,7
	cfont 51,11,MAXCOLS,14,DSBFONT		# ship to addr
end if

# ribbon section
cerase 17,16,17,18
cerase 26,16,26,18
cerase 30,16,30,18
cerase 46,16,46,18
cerase 55,16,55,18
cerase 62,16,62,18
cerase 65,16,65,18
cbox LEFTCOL,15,MAXCOLS,19,MBOXSIZE
cbox LEFTCOL,15,MAXCOLS,17,1,ISHADE
cbox 17,15,26,19
cbox 30,15,46,19
cbox 55,15,62,19
cbox 65,15,65,19
cfont 2,16,16,16,IFONT					# ref #
cfont 18,16,25,16,ICFONT				# shipped dt
cfont 27,16,29,16,ICFONT				# slsp
cfont 31,16,45,16,IFONT					# terms
cfont 47,16,54,16,IFONT					# tax code
cfont 56,16,61,16,IFONT					# doc #
cfont 63,16,64,16,ICFONT				# whs
cfont 66,16,MAXRCOLS,16,IFONT				# ship via

if copy CUSTOMER_COPY,FILE_COPY
	cfont 2,18,16,18,DBFONT				# ref #
	cfont 18,18,25,18,DBCFONT			# shipped dt
	cfont 27,18,29,18,DBCFONT			# slsp
	cfont 31,18,45,18,DBFONT			# terms
	cfont 47,18,54,18,DBFONT			# tax code
	cfont 56,18,61,18,DBFONT			# doc #
	cfont 63,18,64,18,DBCFONT			# whs
	cfont 66,18,MAXRCOLS,18,DBFONT		# ship via
end if
if copy INTERNAL_COPY
	cfont 2,18,16,18,DSBFONT			# ref #
	cfont 18,18,25,18,DSBCFONT			# shipped dt
	cfont 27,18,29,18,DSBCFONT			# slsp
	cfont 31,18,45,18,DSBFONT			# terms
	cfont 47,18,54,18,DSBFONT			# tax code
	cfont 56,18,61,18,DSBFONT			# doc #
	cfont 63,18,64,18,DSBCFONT			# whs
	cfont 66,18,MAXRCOLS,18,DSBFONT		# ship via
end if

# detail
erase "DESCRIPTION@2,20,40,20",-1,0,1,1
erase "Description@2,20,40,20",-1,0,1,1
cerase 43,20,43,20
cerase 53,20,53,20
cerase 56,20,56,20
cerase 66,20,66,20
cerase 69,20,69,20
cerase 93,20,93,60
cbox LEFTCOL,19,MAXCOLS,60,MBOXSIZE
cbox LEFTCOL,19,MAXCOLS,21,1,DSHADE

const XMASK=DESCRIPTION@2,20,40,20
const X1MASK=Description@2,20,40,20
cfont "XMASK",-2,0,2,20,IFONT,ITEM_JUSTIFY	# item
cfont "X1MASK",-2,0,2,20,IFONT,ITEM_JUSTIFY	# item
cfont "XMASK",0,0,42,20,IFONT				# desc
cfont "X1MASK",0,0,42,20,IFONT			# desc
cfont 44,20,52,20,IRFONT				# shipped
cfont 54,20,55,20,ICFONT				# uom
cfont 57,20,65,20,IRFONT				# price
cfont 67,20,68,20,ICFONT				# uom
cfont 70,20,MAXRCOLS,20,ICFONT			# extension

if copy CUSTOMER_COPY,FILE_COPY
	SO_INV_CFONT "XMASK",-2,2,2,60,DBFONT,ITEM_JUSTIFY  # item
	SO_INV_CFONT "X1MASK",-2,2,2,60,DBFONT,ITEM_JUSTIFY # item
	SO_INV_CFONT "XMASK",0,2,43,60,DFONT		# desc
	SO_INV_CFONT "X1MASK",0,2,43,60,DFONT		# desc
	SO_INV_CFONT 44,22,52,60,DBRFONT			# shipped
	SO_INV_CFONT 54,22,55,60,DBCFONT			# uom
	SO_INV_CFONT 57,22,65,60,DBRFONT			# price
	SO_INV_CFONT 67,22,68,60,DBCFONT			# uom
	SO_INV_CFONT 70,22,MAXRCOLS,60,DBPFONT		# extension
end if
if copy INTERNAL_COPY
	SO_INV_CFONT "XMASK",-2,2,2,60,DSBFONT,ITEM_JUSTIFY  # item
	SO_INV_CFONT "X1MASK",-2,2,2,60,DSBFONT,ITEM_JUSTIFY # item
	SO_INV_CFONT "XMASK",0,2,43,60,DSFONT		# desc
	SO_INV_CFONT "X1MASK",0,2,43,60,DSFONT		# desc
	SO_INV_CFONT 44,22,52,60,DSBRFONT			# shipped
	SO_INV_CFONT 54,22,55,60,DSBCFONT			# uom
	SO_INV_CFONT 57,22,65,60,DSBRFONT			# price
	SO_INV_CFONT 67,22,68,60,DSBCFONT			# uom
	SO_INV_CFONT 70,22,MAXRCOLS,60,DSBPFONT		# extension
	cbox 82,19,100,60,MBOXSIZE
	cbox 82,19,100,21,1,DSHADE
	cbox 93,19,93,60
	cfont 82,20,92,20,IRFONT			# cost
	cfont 94,20,99,20,IRFONT			# gm
	SO_INV_CFONT 82,22,92,60,DSBRFONT		# cost
	SO_INV_CFONT 94,22,99,60,DSBRFONT		# gm
end if
# enhance memo lines
if copy CUSTOMER_COPY,FILE_COPY
	SO_INV_FONT "mL@2,22,25,59",3,0,30,1,DFONT	# memo lines
end if
if copy INTERNAL_COPY
	SO_INV_FONT "mL@2,22,25,59",3,0,30,1,DSFONT	# memo lines
end if
erase "mL@2,22,40,59",0,0,2,1				# spec chars
# enhance serial # lines
if copy CUSTOMER_COPY,FILE_COPY
	SO_INV_FONT "sL@2,22,25,59",3,0,4,1,DFONT		# serial lines
	SO_INV_FONT "sL@2,22,25,59",10,0,15,1,DFONT	# serial lines
end if
if copy INTERNAL_COPY
	SO_INV_FONT "sL@2,22,25,59",3,0,4,1,DSFONT	# serial lines
	SO_INV_FONT "sL@2,22,25,59",10,0,15,1,DSFONT	# serial lines
end if
erase "sL@2,22,40,59",0,0,2,1				# spec chars
# handle payment info
if copy CUSTOMER_COPY,FILE_COPY
	SO_INV_FONT "pL@13,22,14,59",2,0,14,1,DFONT	# pymt desc
	SO_INV_FONT "pL@13,22,14,59",17,0,13,1,DBPFONT	# pymt amts
	SO_INV_FONT "pL@13,22,14,59",31,0,40,1,DFONT	# pymt comment
end if
if copy INTERNAL_COPY
	SO_INV_FONT "pL@13,22,14,59",2,0,14,1,DSFONT	# pymt desc
	SO_INV_FONT "pL@13,22,14,59",17,0,13,1,DSBPFONT	# pymt amts
	SO_INV_FONT "pL@13,22,14,59",31,0,40,1,DSFONT	# pymt comment
end if
erase "pL@13,22,14,59",0,0,2,1			# spec chars

# footer
cerase 25,62,100,62
cerase 25,64,100,64
cerase 25,61,25,63
cerase 37,61,37,63
cerase 49,61,49,63
cerase 59,61,59,63
cerase 68,61,68,63
cerase 93,61,93,63
cbox LEFTCOL,60,MAXCOLS,MAXROWS,MBOXSIZE
cbox 25,60,MAXCOLS,64
cbox 25,60,MAXCOLS,62,1,HSHADE
cbox 37,60,49,64
cbox 59,60,68,64
cfont 25.5,61,36,61,IBRFONT			# merchandise
cfont 38,61,48,61,IBRFONT			# misc
cfont 50,61,58,61,IBRFONT			# tax
cfont 60,61,67,61,IBRFONT			# frt
cfont 69,61,MAXRCOLS,61,IBRFONT,10		# tot due

if copy CUSTOMER_COPY,FILE_COPY
	cfont 26,63,36,63,DBRFONT			# merchandise
	cfont 38,63,48,63,DBRFONT			# misc
	cfont 50,63,58,63,DBRFONT			# tax
	cfont 60,63,67,63,DBRFONT			# frt
	cfont 69,63,MAXRCOLS,63,DBRFONT,10		# tot due
end if
if copy INTERNAL_COPY
	cfont 26,63,36,63,DSBRFONT			# merchandise
	cfont 38,63,48,63,DSBRFONT			# misc
	cfont 50,63,58,63,DSBRFONT			# tax
	cfont 60,63,67,63,DSBRFONT			# frt
	cfont 69,63,MAXRCOLS,63,DSBRFONT,9		# tot due
	cerase 83,61,92,61
	cbox 82,60,100,62,1,HSHADE
	cbox 82,62,100,64
	cbox 93,60,93,64
	text 83,61,"TOTAL COST",IBRFONT,9,cols=10	# tot cost
	cfont 94,61,99,61,IBRFONT			# gm
	cfont 83,63,92,63,DSBRFONT,9			# tot cost
	cfont 94,63,99,63,DSBRFONT			# gm
end if
if copy CUSTOMER_COPY,FILE_COPY
	cfont 2,61,24,64,DFONT
	cfont 2,65,MAXCOLS,65,DFONT
end if
if copy INTERNAL_COPY
	cfont 2,61,24,64,DSFONT
	cfont 2,65,MAXCOLS,65,DSFONT
end if

[P/O Purchase Order VI only]
# Print Control	1-66, 2-N, 3-V/I/VI, 4-1/2/B
detect 0,2,"PURCHASE ORDER"
detect 0,7,"~DATEMASK"
detect 0,20,"VENDOR-ITEM"
detect 0,20,"~(!ITEM)|(ITEM!)"

# document options
const MAXCOLS=100
const MAXRCOLS=99
const LEFTCOL=1
const MAXROWS=66
cols MAXCOLS
page MAXROWS
rows MAXROWS

const VENDOR_COPY=1
const FILE_COPY=2
pcopies 2

prepage {
	#get header info for better placement
	title$=trim(get(35,2,40))
	poreprint$=trim(get(91,2,7))
	# get comp info from page or constants?
	compname$=trim(get(35,3,40))
	if compname$="" then \
			compname$="COMP_NAME"; \
			addr1$="COMP_ADDR1"; \
			addr2$="COMP_ADDR2"; \
			addr3$="COMP_ADDR3"; \
			phone$="Phone: COMP_PHONES" \
		else \
			addr1$=trim(get(35,4,46)); \
			addr2$=trim(get(35,5,46)); \
			addr3$=trim(get(35,6,46)); \
			phone$=trim(get(35,7,46)); \
			if phone$="" then if addr3$="" or \
					addr3$(1,1)>="A" then \
					phone$="Phone: COMP_PHONES" \
				else \
					phone$="Phone: "+addr3$,addr3$="" \
				else 	phone$="Phone: "+phone$
	if addr3$="" then addr3$=phone$,phone$=""

	pono$=trim(get(92,3,6))
	popage$=trim(get(97,5,3))
	podate$=trim(get(91,7,8))
	vendor_code$=trim(get(19,10,25))
	cust_code$=""
	shipto_code$=trim(get(69,10,20))
	x=pos(" "=shipto_code$)
	if x then cust_code$=shipto_code$(x+1), \
		shipto_code$=shipto_code$(1,x-1)

	desc_pos=pos("DESCRIPTION"=text$[20])
	# find memo lines and mark them for enhancing later
	for i=22 to 59
		# if vendor item # exists, must be detail line
		if trim(text$[i](2,20))<>"" then continue
		# if item # exists; must be item line
		if trim(text$[i](23,desc_pos-26))<>"" then continue
		# is it a blank line?
		if trim(text$[i](desc_pos,20))="" then continue
		# must be memo line or 2nd desc line
		text$[i](desc_pos-3,2)="mL"
	next i

}

# erase columns !
cerase 1,1,1,MAXROWS
cerase 100,1,100,MAXROWS

# erase rows - or =
cerase 1,1,MAXCOLS,1
cerase 1,15,MAXCOLS,15
cerase 1,17,MAXCOLS,17
cerase 1,19,MAXCOLS,19
cerase 1,21,MAXCOLS,21
cerase 1,60,MAXCOLS,60
cerase 1,MAXROWS,MAXCOLS,MAXROWS

# header
cerase 1,1,MAXCOLS,10
cbox LEFTCOL,1,MAXCOLS,MAXROWS,MBOXSIZE
cbox LEFTCOL,1,MAXCOLS,10,MBOXSIZE
LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
text 1,2,{title$},HBRFONT,16,cols=MAXRCOLS
text 1,3,{poreprint$},HRFONT,12,cols=MAXRCOLS
text 1,2,{compname$},HBCFONT,14,cols=MAXRCOLS
text 1,3.2,{addr1$},HCFONT,12,cols=MAXRCOLS
text 1,4.3,{addr2$},HCFONT,12,cols=MAXRCOLS
text 1,5.4,{addr3$},HCFONT,12,cols=MAXRCOLS
text 1,6.5,{phone$},HCFONT,12,cols=MAXRCOLS
text 1,7.5,"COMP_EMAIL",HCFONT,cols=MAXRCOLS
text 1,8.5,"COMP_WEBSITE",HCFONT,cols=MAXRCOLS
cbox 84,3.75,MAXCOLS,5,1,100
if copy VENDOR_COPY
	text 85,4.5,"Vendor Copy",HBCFONT,12,cols=15,shade 0
end if
if copy FILE_COPY
	text 85,4.5,"File Copy",HBCFONT,12,cols=15,shade 0
end if

# right header
cbox 84,5.5,MAXCOLS,10
cbox 84,5.5,92,10,1,ISHADE
cbox 84,7,MAXCOLS,8.5
text 85,6.25,"Number",IFONT
text 85,7.75,"Date",IFONT
text 85,9.25,"Page",IFONT
text 93,6.25,{pono$},DSBFONT
text 93,7.75,{podate$},DSBFONT
text 93,9.25,{popage$},DSBFONT

# Vendor section
cerase 1,10,MAXCOLS,10
cbox LEFTCOL,10,MAXCOLS,15,MBOXSIZE
cbox LEFTCOL,10,12,15,1,ISHADE
text 2,11,"Vendor:",IFONT
text 2,12,{vendor_code$},DSBFONT
cmove 12,11,49,14,13,11
cfont 13,11,49,14,DSBFONT				# vendor addr

# ship to section
cbox 49,10,60,15,1,ISHADE
text 50,11,"Ship to:",IFONT
text 50,12,{shipto_code$},DSBFONT
text 50,13,{cust_code$},DSBFONT
cfont 61,11,MAXCOLS,14,DSBFONT			# ship to addr

# ribbon section
cerase 7,16,7,18
cerase 23,16,23,18
cerase 39,16,39,18
cerase 55,16,55,18
cerase 63,16,63,18
cerase 79,16,79,18
cerase 88,16,88,18
cbox LEFTCOL,15,MAXCOLS,19,MBOXSIZE
cbox LEFTCOL,15,MAXCOLS,17,1,ISHADE
cbox 7,15,23,19
cbox 39,15,55,19
cbox 63,15,79,19
cbox 88,15,88,19
cfont 1,16,6,16,ICFONT				# buyer
cfont 8,16,22,16,IFONT				# terms
cfont 24,16,38,16,IFONT				# ship via
cfont 40,16,54,16,IFONT				# fob
cfont 56,16,62,16,IFONT				# frt
cfont 64,16,78,16,IFONT				# ref #
cfont 80,16,87,16,ICFONT			# expected dt
cfont 89,16,MAXCOLS,16,IFONT			# customer

cfont 2,18,6,18,DSBCFONT			# buyer
cfont 8,18,22,18,DSBFONT			# terms
cfont 24,18,38,18,DSBFONT			# ship via
cfont 40,18,54,18,DSBFONT			# fob
cfont 56,18,62,18,DSBFONT			# frt
cfont 64,18,78,18,DSBFONT			# ref #
cfont 80,18,87,18,DSBCFONT			# expected dt
cfont 89,18,MAXCOLS,18,DSBFONT		# customer

# change ! to box in detail section
cerase 22,20,22,59
erase "DESCRIPTION@23,20,63,20",-1,0,1,40
erase "!@63,20,63,59",0,0,1,1
erase "!@73,20,73,59",0,0,1,1
cerase 76,20,76,59
cerase 86,20,86,59
cerase 89,20,89,59
cbox LEFTCOL,19,MAXCOLS,60,MBOXSIZE
cbox LEFTCOL,19,MAXCOLS,21,1,DSHADE
cbox 22,19,22,60
box "DESCRIPTION@23,20,63,20",-1,-1,1,41
cbox 63,19,63,60
cbox 73,19,73,60
cbox 76,19,76,60
cbox 86,19,86,60
cbox 89,19,89,60

# detail headers
const XMASK=DESCRIPTION@23,20,63,20
cfont 2,20,21,20,IFONT,ITEM_JUSTIFY			# vndr-item
cfont "XMASK",-2,0,23,20,IFONT,ITEM_JUSTIFY	# item
cfont "XMASK",0,0,63,20,IFONT				# desc
cfont 64,20,72,20,IRFONT				# units
cfont 74,20,75,20,ICFONT				# uom
cfont 77,20,85,20,IRFONT				# cost
cfont 87,20,88,20,ICFONT				# uom
cfont 90,20,MAXRCOLS,20,ICFONT			# extension

# detail
PO_CFONT 2,22,21,59,DSBFONT,ITEM_JUSTIFY		# vndr-item
PO_CFONT "XMASK",-2,2,23,59,DSBFONT,ITEM_JUSTIFY # item
PO_CFONT "XMASK",0,2,63,59,DSFONT			# desc
PO_CFONT 64,22,72,59,DSBRFONT				# units
PO_CFONT 74,22,75,59,DSBCFONT				# uom
PO_CFONT 77,22,85,59,DSBRFONT				# cost
PO_CFONT 87,22,88,59,DSBCFONT				# uom
PO_CFONT 90,22,MAXRCOLS,59,DSBPFONT			# extension
PO_FONT "mL@21,22,43,59",3,0,40,1,DSFONT		# memo lines
erase "mL@21,22,43,59",0,0,2,1			# spec chars

# footer section
cerase 56,62,MAXCOLS,62
cerase 56,64,MAXCOLS,64
cerase 56,60,56,64
cerase 68,60,68,64
cerase 78,60,78,64
cerase 87,60,87,64
cbox LEFTCOL,60,MAXCOLS,MAXROWS,MBOXSIZE
cbox 56,60,MAXCOLS,62,1,HSHADE
cbox 56,62,MAXCOLS,64
cbox 68,60,78,64
cbox 87,60,87,64

cfont 57,61,67,61,IBRFONT			# amt
cfont 69,61,77,61,IBRFONT			# tax
cfont 79,61,86,61,IBRFONT			# frt
cfont 88,61,MAXRCOLS,61,IBRFONT,9		# tot

cfont 57,63,67,63,DSBRFONT			# amt
cfont 69,63,77,63,DSBRFONT			# tax
cfont 79,63,86,63,DSBRFONT			# frt
cfont 88,63,MAXRCOLS,63,DSBRFONT,9		# tot

cfont 1,61,55,65,IFONT				# comments
cfont 57,65,MAXCOLS,65,IFONT			# resale license

[P/O Purchase Order V or I]
# Print Control	1-66, 2-N, 3-V/I/VI, 4-1/2/B
detect 0,2,"PURCHASE ORDER"
detect 0,7,"~DATEMASK"

# document options
const MAXCOLS=100
const MAXRCOLS=99
const LEFTCOL=1
const MAXROWS=66
cols MAXCOLS
page MAXROWS
rows MAXROWS

const VENDOR_COPY=1
const FILE_COPY=2
pcopies 2

prepage {
	#get header info for better placement
	title$=trim(get(35,2,40))
	poreprint$=trim(get(91,2,7))
	# get comp info from page or constants?
	compname$=trim(get(35,3,40))
	if compname$="" then \
			compname$="COMP_NAME"; \
			addr1$="COMP_ADDR1"; \
			addr2$="COMP_ADDR2"; \
			addr3$="COMP_ADDR3"; \
			phone$="Phone: COMP_PHONES" \
		else \
			addr1$=trim(get(35,4,46)); \
			addr2$=trim(get(35,5,46)); \
			addr3$=trim(get(35,6,46)); \
			phone$=trim(get(35,7,46)); \
			if phone$="" then if addr3$="" or \
					addr3$(1,1)>="A" then \
					phone$="Phone: COMP_PHONES" \
				else \
					phone$="Phone: "+addr3$,addr3$="" \
				else 	phone$="Phone: "+phone$
	if addr3$="" then addr3$=phone$,phone$=""

	pono$=trim(get(92,3,6))
	popage$=trim(get(97,5,3))
	podate$=trim(get(91,7,8))
	vendor_code$=trim(get(19,10,25))
	cust_code$=""
	shipto_code$=trim(get(69,10,20))
	x=pos(" "=shipto_code$)
	if x then cust_code$=shipto_code$(x+1), \
		shipto_code$=shipto_code$(1,x-1)
}


# erase columns !
cerase 1,1,1,MAXROWS
cerase 100,1,100,MAXROWS

# erase rows - or =
cerase 1,1,MAXCOLS,1
cerase 1,15,MAXCOLS,15
cerase 1,17,MAXCOLS,17
cerase 1,19,MAXCOLS,19
cerase 1,21,MAXCOLS,21
cerase 1,60,MAXCOLS,60
cerase 1,MAXROWS,MAXCOLS,MAXROWS

# header
cerase 1,1,MAXCOLS,10
cbox LEFTCOL,1,MAXCOLS,MAXROWS,MBOXSIZE
cbox LEFTCOL,1,MAXCOLS,10,MBOXSIZE
LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
text 1,2,{title$},HBRFONT,16,cols=MAXRCOLS
text 1,3,{poreprint$},HRFONT,12,cols=MAXRCOLS
text 1,2,{compname$},HBCFONT,14,cols=MAXRCOLS
text 1,3.2,{addr1$},HCFONT,12,cols=MAXRCOLS
text 1,4.3,{addr2$},HCFONT,12,cols=MAXRCOLS
text 1,5.4,{addr3$},HCFONT,12,cols=MAXRCOLS
text 1,6.5,{phone$},HCFONT,12,cols=MAXRCOLS
text 1,7.5,"COMP_EMAIL",HCFONT,cols=MAXRCOLS
text 1,8.5,"COMP_WEBSITE",HCFONT,cols=MAXRCOLS
cbox 84,3.75,MAXCOLS,5,1,100
if copy VENDOR_COPY
	text 85,4.5,"Vendor Copy",HBCFONT,12,cols=15,shade 0
end if
if copy FILE_COPY
	text 85,4.5,"File Copy",HBCFONT,12,cols=15,shade 0
end if

# right header
cbox 84,5.5,MAXCOLS,10
cbox 84,5.5,92,10,1,ISHADE
cbox 84,7,MAXCOLS,8.5
text 85,6.25,"Number",IFONT
text 85,7.75,"Date",IFONT
text 85,9.25,"Page",IFONT
text 93,6.25,{pono$},DSBFONT
text 93,7.75,{podate$},DSBFONT
text 93,9.25,{popage$},DSBFONT

# Vendor section
cerase 1,10,MAXCOLS,10
cbox LEFTCOL,10,MAXCOLS,15,MBOXSIZE
cbox LEFTCOL,10,12,15,1,ISHADE
text 2,11,"Vendor:",IFONT
text 2,12,{vendor_code$},DSBFONT
cmove 12,11,49,14,13,11
cfont 13,11,49,14,DSBFONT				# vendor addr

# ship to section
cbox 49,10,60,15,1,ISHADE
text 50,11,"Ship to:",IFONT
text 50,12,{shipto_code$},DSBFONT
text 50,13,{cust_code$},DSBFONT
cfont 61,11,MAXCOLS,14,DSBFONT			# ship to addr

# ribbon section
cerase 7,16,7,18
cerase 23,16,23,18
cerase 39,16,39,18
cerase 55,16,55,18
cerase 63,16,63,18
cerase 79,16,79,18
cerase 88,16,88,18
cbox LEFTCOL,15,MAXCOLS,19,MBOXSIZE
cbox LEFTCOL,15,MAXCOLS,17,1,ISHADE
cbox 7,15,23,19
cbox 39,15,55,19
cbox 63,15,79,19
cbox 88,15,88,19
cfont 1,16,6,16,ICFONT				# buyer
cfont 8,16,22,16,IFONT				# terms
cfont 24,16,38,16,IFONT				# ship via
cfont 40,16,54,16,IFONT				# fob
cfont 56,16,62,16,IFONT				# frt
cfont 64,16,78,16,IFONT				# ref #
cfont 80,16,87,16,ICFONT			# expected dt
cfont 89,16,MAXCOLS,16,IFONT			# customer

cfont 2,18,6,18,DSBCFONT			# buyer
cfont 8,18,22,18,DSBFONT			# terms
cfont 24,18,38,18,DSBFONT			# ship via
cfont 40,18,54,18,DSBFONT			# fob
cfont 56,18,62,18,DSBFONT			# frt
cfont 64,18,78,18,DSBFONT			# ref #
cfont 80,18,87,18,DSBCFONT			# expected dt
cfont 89,18,MAXCOLS,18,DSBFONT		# customer

# detail headers
const XMASK=DESCRIPTION@7,20,34,20
erase "XMASK",-1,0,1,40
cerase 63,19,63,60
cerase 73,19,73,60
cerase 76,19,76,60
cerase 86,19,86,60
cerase 89,19,89,60
cbox LEFTCOL,19,MAXCOLS,60,MBOXSIZE
cbox LEFTCOL,19,MAXCOLS,21,1,DSHADE
box "XMASK",-1,-1,1,41
cbox 63,19,73,60
cbox 76,19,86,60
cbox 89,19,89,60

# detail headers
cfont "XMASK",-2,0,2,20,IFONT,ITEM_JUSTIFY	# vndr/item
cfont "XMASK",0,0,62,20,IFONT				# desc
cfont 64,20,72,20,IRFONT				# units
cfont 74,20,75,20,ICFONT				# uom
cfont 77,20,85,20,IRFONT				# cost
cfont 87,20,88,20,ICFONT				# uom
cfont 90,20,MAXRCOLS,20,ICFONT			# extension

# detail
PO_CFONT "XMASK",-2,2,2,59,DSBFONT,ITEM_JUSTIFY	# vndr/item
PO_CFONT "XMASK",0,2,63,59,DSFONT			# desc
PO_CFONT 64,22,72,59,DSBRFONT				# units
PO_CFONT 74,22,75,59,DSBCFONT				# uom
PO_CFONT 77,22,85,59,DSBRFONT				# cost
PO_CFONT 87,22,88,59,DSBCFONT				# uom
PO_CFONT 90,22,MAXRCOLS,59,DSBPFONT			# extension

# footer section
cerase 56,62,MAXCOLS,62
cerase 56,64,MAXCOLS,64
cerase 56,60,56,64
cerase 68,60,68,64
cerase 78,60,78,64
cerase 87,60,87,64
cbox LEFTCOL,60,MAXCOLS,MAXROWS,MBOXSIZE
cbox 56,60,MAXCOLS,62,1,HSHADE
cbox 56,62,MAXCOLS,64
cbox 68,60,78,64
cbox 87,60,87,64

cfont 57,61,67,61,IBRFONT			# amt
cfont 69,61,77,61,IBRFONT			# tax
cfont 79,61,86,61,IBRFONT			# frt
cfont 88,61,MAXRCOLS,61,IBRFONT,9		# tot

cfont 57,63,67,63,DSBRFONT			# amt
cfont 69,63,77,63,DSBRFONT			# tax
cfont 79,63,86,63,DSBRFONT			# frt
cfont 88,63,MAXRCOLS,63,DSBRFONT,9		# tot

cfont 1,61,55,65,IFONT				# comments
cfont 57,65,MAXCOLS,65,IFONT			# resale license

[S/O Quote]
# Quote Control	1-66, 2-N, 3-1/2/B
detect 0,2,"QUOTE"
detect 0,16,"EXPIRES"

# document options
const MAXCOLS=80
const MAXRCOLS=79
const LEFTCOL=1
const MAXROWS=66
cols MAXCOLS
page MAXROWS
rows MAXROWS

const CUSTOMER_COPY=1
const FILE_COPY=2
pcopies 2

prepage {
	#get header info for better placement
	title$=trim(get(35,2,5))
	invreprint$=trim(get(72,2,7))
	# get comp info from page or constants?
	compname$=trim(get(20,3,40))
	if compname$="" then \
			compname$="COMP_NAME"; \
			addr1$="COMP_ADDR1"; \
			addr2$="COMP_ADDR2"; \
			addr3$="COMP_ADDR3"; \
			phone$="Phone: COMP_PHONES" \
		else \
			addr1$=trim(get(20,4,46)); \
			addr2$=trim(get(20,5,46)); \
			addr3$=trim(get(20,6,46)); \
			phone$=trim(get(20,7,46)); \
			if phone$="" then if addr3$="" or \
					addr3$(1,1)>="A" then \
					phone$="Phone: COMP_PHONES" \
				else \
					phone$="Phone: "+addr3$,addr3$="" \
				else 	phone$="Phone: "+phone$
	if addr3$="" then addr3$=phone$,phone$=""

	invno$=trim(get(72,3,8))
	invpage$=trim(get(77,5,3))
	invdate$=trim(get(71,7,8))
	cust_code$=trim(get(57,10,23))
	shipto_code$=trim(get(15,10,15))

	# find/mark memo lines
	desc_pos=pos("DESCRIPTION"=text$[22])
	for i=24 to 59
		if trim(text$[i](2,desc_pos-3))="" then \
			text$[i](desc_pos-3,2)="mL"
	next i
}

# erase columns !
cerase 1,1,1,MAXROWS
cerase MAXCOLS,1,MAXCOLS,MAXROWS

# erase rows - or =
cerase 1,1,MAXCOLS,1
cerase 1,15,MAXCOLS,15
cerase 1,17,MAXCOLS,17
cerase 1,19,MAXCOLS,19
cerase 1,21,MAXCOLS,21
cerase 1,23,MAXCOLS,23
cerase 1,60,MAXCOLS,60
cerase 1,MAXROWS,MAXCOLS,MAXROWS

# header
cerase 1,1,MAXCOLS,10,5
cbox LEFTCOL,1,MAXCOLS,MAXROWS,MBOXSIZE
cbox LEFTCOL,1,MAXCOLS,10,5
LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
text 1,2,{title$},HBRFONT,16,cols=MAXRCOLS
text 1,3.2,{invreprint$},HRFONT,12,cols=MAXRCOLS
text 1,2,{compname$},HBCFONT,14,cols=MAXRCOLS
text 1,3.2,{addr1$},HCFONT,12,cols=MAXRCOLS
text 1,4.3,{addr2$},HCFONT,12,cols=MAXRCOLS
text 1,5.4,{addr3$},HCFONT,12,cols=MAXRCOLS
text 1,6.5,{phone$},HCFONT,12,cols=MAXRCOLS
text 1,7.5,"COMP_EMAIL",HCFONT,cols=MAXRCOLS
text 1,8.5,"COMP_WEBSITE",HCFONT,cols=MAXRCOLS
cbox 64,3.75,MAXCOLS,5.25,1,100
if copy CUSTOMER_COPY
	text 65,4.5,"Customer Copy",HBCFONT,12,cols=15,shade 0
end if
if copy FILE_COPY
	text 65,4.5,"File Copy",HBCFONT,12,cols=15,shade 0
end if

# right header
cbox 64,5.5,MAXCOLS,10
cbox 64,5.5,72,10,1,ISHADE
cbox 64,7,MAXCOLS,7
cbox 64,8.5,MAXCOLS,8.5
text 65,6.25,"Number",IFONT
text 65,7.75,"Date",IFONT
text 65,9.25,"Page",IFONT
text 73,6.25,{invno$},DBFONT
text 73,7.75,{invdate$},DBFONT
text 73,9.25,{invpage$},DBFONT

# ship to section
cbox LEFTCOL,10,MAXCOLS,15,MBOXSIZE
cbox LEFTCOL,10,10,15,1,ISHADE
text 2,11,"Ship To:",IFONT
text 2,12,{shipto_code$},DSBFONT
cmove 7,11,41,14,11,11
cfont 11,11,40,14,DBFONT			# ship to addr

# bill to section
cbox 41,10,50,15,1,ISHADE
text 42,11,"Bill To:",IFONT
text 42,12,{cust_code$},DSBFONT
cmove 49,11,MAXRCOLS,14,51,11
cfont 51,11,MAXCOLS,14,DBFONT			# bill to addr

# ribbon 1 section
cerase 17,15,17,19
cerase 27,15,27,19
cerase 32,15,32,19
cerase 48,15,48,19
cerase 52,15,52,19
cerase 60,15,60,19
cbox LEFTCOL,15,MAXCOLS,21,MBOXSIZE
cbox LEFTCOL,15,MAXCOLS,17,1,ISHADE
cbox LEFTCOL,15,MAXCOLS,19
cbox 17,15,27,19
cbox 32,15,48,19
cbox 52,15,60,19
cfont 2,16,16,16,IFONT				# ref #
cfont 18,16,26,16,ICFONT			# expires
cfont 28,16,31,16,ICFONT			# salesperson
cfont 33,16,47,16,IFONT				# terms
cfont 49,16,51,16,ICFONT			# whs
cfont 53,16,59,16,ICFONT			# frt
cfont 61,16,MAXCOLS,16,IFONT			# ship via

cfont 2,18,16,18,DBFONT				# ref #
cfont 18,18,26,18,DBCFONT			# expires
cfont 28,18,31,18,DBCFONT			# salesperson
cfont 33,18,47,18,DBFONT			# terms
cfont 49,18,51,18,DBCFONT			# whs
cfont 53,18,59,18,DBCFONT			# frt
cfont 61,18,MAXCOLS,18,DBFONT			# ship via

# ribbon 2 section
cerase LEFTCOL,19,MAXCOLS,19
cerase LEFTCOL,21,MAXCOLS,21
cbox LEFTCOL,19,12,21,1,ISHADE
cbox 12,19,17,21
cbox 17,19,27,21,1,ISHADE
cfont 2,20,11,20,IRFONT
cfont 13,20,16,20,DBFONT				# quoted by
cmove 18,20,27,20,17,20
cfont 17,20,26,20,IRFONT				# quoted to
cfont 28,20,MAXCOLS,20,DBFONT

# detail
const XMASK=DESCRIPTION@2,22,40,22
erase "XMASK",-1,-1,1,40
erase "!@43,21,43,60",0,0,1,1
cerase 53,21,53,60
cerase 56,21,56,60
cerase 66,21,66,60
cerase 69,21,69,60
cbox LEFTCOL,21,MAXCOLS,60,MBOXSIZE
cbox LEFTCOL,21,MAXCOLS,23,1,DSHADE
box "XMASK",-1,-1,1,39
cbox 43,21,43,60
cbox 53,21,56,60
cbox 66,21,69,60
cfont "XMASK",-2,0,2,22,IFONT,ITEM_JUSTIFY	# item
cfont "XMASK",0,0,42,22,IFONT				# desc
cfont 44,22,52,22,IRFONT				# ordered
cfont 54,22,55,22,ICFONT				# uom
cfont 57,22,65,22,IRFONT				# price
#cerase 57,22,65,22
#text 57,22,{trim(get(57,22,9))},IRFONT,cols=8	# price
cfont 67,22,68,22,ICFONT				# uom
cfont 70,22,MAXRCOLS,22,ICFONT			# extension

SO_QUOTE_CFONT "XMASK",-2,2,2,60,DBFONT,ITEM_JUSTIFY # item
SO_QUOTE_CFONT "XMASK",0,2,43,60,DFONT		# desc
const X1MASK="[0-9][0-9]@77,24,79,59"
SO_QUOTE_FONT "~\.X1MASK",-33,0,9,1,DBRFONT	# ordered
SO_QUOTE_CFONT 54,24,55,60,DBCFONT			# uom
SO_QUOTE_CFONT 57,24,65,60,DBRFONT			# price
SO_QUOTE_CFONT 67,24,68,60,DBCFONT			# uom
SO_QUOTE_CFONT 70,24,MAXRCOLS,60,DBPFONT		# extension
SO_QUOTE_FONT "mL@2,24,25,59",3,0,40,1,DFONT	# memo lines
erase "mL@2,24,40,59",0,0,2,1				# spec chars

# footer
cerase LEFTCOL,62,MAXCOLS,62
cerase LEFTCOL,64,MAXCOLS,64
cerase 24,60,24,64
cerase 36,60,36,64
cerase 48,60,48,64
cerase 58,60,58,64
cerase 67,60,67,64
cbox LEFTCOL,60,MAXCOLS,MAXROWS,MBOXSIZE
cbox 24,60,MAXCOLS,62,1,HSHADE
cbox 24,62,MAXCOLS,64
cbox 36,60,48,64
cbox 58,60,67,64
cfont 25,61,35,61,IBRFONT				# merch
cfont 37,61,47,61,IBRFONT				# misc
cfont 49,61,57,61,IBRFONT				# tax
cfont 59,61,66,61,IBRFONT				# frt
cfont 68,61,MAXRCOLS,61,IBRFONT,10			# tot

cfont 25,63,35,63,DBRFONT				# merchandise
cfont 37,63,47,63,DBRFONT				# misc
cfont 49,63,57,63,DBRFONT				# tax
cfont 59,63,66,63,DBRFONT				# frt
cfont 68,63,MAXRCOLS,63,DBPFONT,10			# tot

cfont 2,65,60,65,DFONT

[A/R Statement]
# Statement Control	1-66, 2-N, 3-Y, 4-Y/N, 5-Y, 6-3
# handles both statement and statement with tearoff
# in both cases, a remittance copy is printed
detect 0,2,"STATEMENT"
detect 0,16,"PYMT DTE"

# document options
const MAXCOLS=80
const MAXRCOLS=79
const LEFTCOL=1
const MAXROWS=66
cols MAXCOLS
page MAXROWS
rows MAXROWS

const FILE_TOTALS_COPY=1
const FILE_CONT_COPY=2
const FILE_COPY="1,2"
const CUSTOMER_TOTALS_COPY=3
const CUSTOMER_CONT_COPY=4
const CUSTOMER_COPY="3,4"
const REMIT_TOTALS_COPY=5
const REMIT_CONT_COPY=6
const REMIT_COPY="5,6"
const NOT_RECAP_COPY="1,2,3,4,5,6"
const RECAP_COPY=7
const TOTALS_COPY="1,3,5"
const CONT_COPY="2,4,6"
pcopies 7

prepage {
	title$="STATEMENT"
	# get comp info from page or constants?
	compname$=trim(get(20,4,40))
	if compname$="" then \
			compname$="COMP_NAME"; \
			addr1$="COMP_ADDR1"; \
			addr2$="COMP_ADDR2"; \
			addr3$="COMP_ADDR3"; \
			phone$="Phone: COMP_PHONES" \
		else \
			addr1$=trim(get(20,5,35)); \
			addr2$=trim(get(20,6,46)); \
			addr3$=trim(get(20,7,35)); \
			phone$=trim(get(20,8,35)); \
			if phone$="" then if addr3$="" or \
					addr3$(1,1)>="A" then \
					phone$="Phone: COMP_PHONES" \
				else \
					phone$="Phone: "+addr3$,addr3$="" \
				else 	phone$="Phone: "+phone$
	if addr3$="" then addr3$=phone$,phone$=""

	stmtpage$=trim(get(71,5,3))
	stmtdate$=trim(get(65,7,8))
	cust_code$=trim(get(5,10,25))
	# look for remark lines
	for i=18 to 61
		if text$[i](1,3)="!==" or text$[i](1,3)="!--" then \
			text$[i](2,1)="*";exitto end_look
	next i
end_look:
}

precopy {
	if copy=RECAP_COPY and cust_code$<>"RECAP" then skip=1
	if copy<>RECAP_COPY and cust_code$="RECAP" then skip=1
	x$=trim(get(66,64,9))
	if x$="CONTINUED" and (copy=FILE_TOTALS_COPY or \
		copy=CUSTOMER_TOTALS_COPY or \
		copy=REMIT_TOTALS_COPY) then skip=1
	if x$<>"CONTINUED" and (copy=FILE_CONT_COPY or \
		copy=CUSTOMER_CONT_COPY or \
		copy=REMIT_CONT_COPY) then skip=1
}

# erase columns !
cerase 1,1,1,MAXROWS
cerase 75,1,75,MAXROWS

# erase rows - or =
cerase 1,1,MAXCOLS,1
cerase 1,15,MAXCOLS,15
cerase 1,17,MAXCOLS,17
cerase 1,63,MAXCOLS,63
cerase 1,65,MAXCOLS,65
cerase 1,MAXROWS,MAXCOLS,MAXROWS

# erase tearoff section
cerase 76,1,98,MAXROWS

# header
cerase 1,1,MAXCOLS,10
cbox LEFTCOL,1,MAXCOLS,MAXROWS,MBOXSIZE
cbox LEFTCOL,1,MAXCOLS,10,MBOXSIZE
LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
text 1,2,{title$},HBRFONT,16,cols=MAXRCOLS
text 1,2,{compname$},HBCFONT,14,cols=MAXRCOLS
text 1,3.2,{addr1$},HCFONT,12,cols=MAXRCOLS
text 1,4.3,{addr2$},HCFONT,12,cols=MAXRCOLS
text 1,5.4,{addr3$},HCFONT,12,cols=MAXRCOLS
text 1,6.5,{phone$},HCFONT,12,cols=MAXRCOLS
text 1,7.5,"COMP_EMAIL",HCFONT,cols=MAXRCOLS
text 1,8.5,"COMP_WEBSITE",HCFONT,cols=MAXRCOLS
cbox 64,3.75,MAXCOLS,5,1,100
if copy FILE_COPY
	text 65,4.5,"File Copy",HBCFONT,12,cols=15,shade 0
end if
if copy CUSTOMER_COPY
	text 65,4.5,"Customer Copy",HBCFONT,12,cols=15,shade 0
end if
if copy REMIT_COPY
	text 65,4.5,"Remittance Copy",HBCFONT,12,cols=15,shade 0
end if
if copy RECAP_COPY
	text 65,4.5,"Recap Copy",HCBFONT,12,cols=15,shade 0
end if

# right header
cbox 64,7,MAXCOLS,10
cbox 64,7,72,10,1,ISHADE
cbox 64,8.5,MAXCOLS,8.5
text 65,7.75,"Date",IFONT
text 65,9.25,"Page",IFONT
text 73,7.75,{stmtdate$},DBFONT
text 73,9.25,{stmtpage$},DBFONT

# to section
cbox LEFTCOL,10,MAXCOLS,15,MBOXSIZE
cbox LEFTCOL,10,11,15,1,ISHADE
text 2,11,"To:",IFONT
text 2,12,{cust_code$},DBFONT
cfont 12,11,51,14,DBFONT			# to addr

# detail
if copy NOT_RECAP_COPY
	cerase "*==@2,18,4,61",8,0,10,15		# remove vert !
	cerase "*==@2,18,4,61",16,0,18,15
	cerase "*==@2,18,4,61",25,0,27,15
	cerase "*==@2,18,4,61",37,0,39,15
	cerase "*==@2,18,4,61",46,0,48,15
	cerase "*==@2,18,4,61",58,0,60,15
	cerase "*--@2,18,4,61",8,0,10,15		# remove vert !
	cerase "*--@2,18,4,61",16,0,18,15
	cerase "*--@2,18,4,61",25,0,27,15
	cerase "*--@2,18,4,61",37,0,39,15
	cerase "*--@2,18,4,61",46,0,48,15
	cerase "*--@2,18,4,61",58,0,60,15
	cerase 63,61,63,15

	cbox LEFTCOL,15,MAXCOLS,61,MBOXSIZE
	cbox LEFTCOL,15,MAXCOLS,17,1,DSHADE
	cbox "*==@2,18,4,61",9,0,10,15		# draw vert lns
	cbox "*==@2,18,4,61",17,0,18,15
	cbox "*==@2,18,4,61",26,0,27,15
	cbox "*==@2,18,4,61",38,0,39,15
	cbox "*==@2,18,4,61",47,0,48,15
	cbox "*==@2,18,4,61",59,0,60,15
	cbox "*--@2,18,4,61",9,0,10,15
	cbox "*--@2,18,4,61",17,0,18,15
	cbox "*--@2,18,4,61",26,0,27,15
	cbox "*--@2,18,4,61",38,0,39,15
	cbox "*--@2,18,4,61",47,0,48,15
	cbox "*--@2,18,4,61",59,0,60,15
	cbox 63,61,63,15
	cbox 75,61,75,15

	cfont 1,16,9,16,ICFONT				# dt
	cfont 11,16,17,16,IFONT				# inv #
	cfont 19,16,26,16,ICFONT			# due dt
	cfont 28,16,38,16,ICFONT			# amt
	cfont 40,16,47,16,ICFONT			# pymt dt
	cfont 49,16,59,16,ICFONT			# pymt amt
	cfont 61,16,62,16,ICFONT			# type
	cfont 64,16,74,16,IBCFONT			# bal
	text 76,15.5,"Mark for",ICFONT,cols=4
	text 76,16.5,"Payment",ICFONT,cols=4

	const XMASK="[0-9][0-9]@72,18,74,60"
	AR_STMT_FONT "~\.XMASK",-71,0,9,1,DBCFONT	# dt
	AR_STMT_FONT "~\.XMASK",-61,0,7,1,DFONT	# inv #
	AR_STMT_FONT "~\.XMASK",-53,0,8,1,DCFONT	# duedt
	AR_STMT_FONT "~\.XMASK",-44,0,11,1,DBPFONT# amt
	AR_STMT_FONT "~\.XMASK",-32,0,8,1,DCFONT # dt
	AR_STMT_FONT "~\.XMASK",-23,0,11,1,DBPFONT# amt
	AR_STMT_FONT "~\.XMASK",-11,0,2,1,DCFONT	# type
	AR_STMT_CFONT 64,18,74,60,DBPFONT		# bal
	# payment only w/o bal showing
	const X1MASK="[0-9][0-9]@57,18,59,60"
	AR_STMT_FONT "~\.X1MASK",-17,0,8,1,DCFONT 	# dt
	AR_STMT_FONT "~\.X1MASK",-8,0,11,1,DBPFONT 	# amt
	AR_STMT_FONT "~\.X1MASK",4,0,2,1,DCFONT		# type
end if
if copy RECAP_COPY
	cerase 1,15,MAXCOLS,60
	cbox LEFTCOL,15,MAXCOLS,61
	text 1,60,"TOTAL DUE RECAP",HBCFONT,14,cols=MAXCOLS
end if

# message area
if copy NOT_RECAP_COPY
	erase "*==@2,18,4,60",-1,0,63,1
	cbox "*==@2,18,4,60",-1,0,63,61
	cfont "*==@2,18,4,60",0,1,62,60,IFONT
	erase "*--@2,18,4,60",-1,0,63,1
	cbox "*--@2,18,4,60",-1,0,63,61
	cfont "*--@2,18,4,60",0,1,62,60,IFONT
end if

# continued
if copy CONT_COPY
	cerase "*==@2,61,4,61",-1,0,MAXCOLS,61
	cerase "===@2,61,4,61",-1,0,MAXCOLS,61
	cerase 1,62,MAXCOLS,MAXROWS
	cbox LEFTCOL,61,MAXCOLS,MAXROWS
	text 1,65,"CONTINUED",HBCFONT,12,cols=MAXCOLS
end if

# footer
cerase "*==@2,61,4,61",-1,0,MAXCOLS,61
cerase "===@2,61,4,61",-1,0,MAXCOLS,61
if copy TOTALS_COPY,RECAP_COPY
	cerase 14,61,14,MAXROWS
	cerase 26,61,26,MAXROWS
	cerase 38,61,38,MAXROWS
	cerase 50,61,50,MAXROWS
	cerase 62,61,62,MAXROWS
	cbox LEFTCOL,61,MAXCOLS,MAXROWS,MBOXSIZE
	cbox LEFTCOL,61,MAXCOLS,63,1,HSHADE
	cbox LEFTCOL,63,MAXCOLS,64.5
	cbox 14,61,26,64.5
	cbox 38,61,50,64.5
	cbox 62,61,75,64.5
	cfont 1,62,13,62,IBRFONT			# current
	cfont 15,62,25,62,IBRFONT			# 1-30
	cfont 27,62,37,62,IBRFONT			# 31-60
	cfont 39,62,49,62,IBRFONT			# 61-90
	cfont 51,62,61,62,IBRFONT			# over 90
	cfont 63,62,74,62,IBRFONT,10			# tot due

	cfont 1,64,13,64,DBRFONT			# current
	cfont 15,64,25,64,DBRFONT			# 1-30
	cfont 27,64,37,64,DBRFONT			# 31-60
	cfont 39,64,49,64,DBRFONT			# 61-90
	cfont 51,64,61,64,DBRFONT			# over 90
	cfont 63,64,74,64,DBRFONT,10			# tot due
end if

[I/C transfer ticket]
# Static Control	4-66, 5-N, 6-1/2/B
detect 0,2,"TRANSFER TICKET PRINT"

# document options
const MAXCOLS=85
const MAXRCOLS=84
const LEFTCOL=1
const MAXROWS=66
cols MAXCOLS
page MAXROWS
rows MAXROWS

const WAREHOUSE_COPY=1
const FILE_COPY=2
pcopies 2

prepage {
	#get header info for better placement
	title$=trim(get(25,2,40))
	x=pos("PRINT"=title$)
	title$=title$(1,x-2)
	invreprint$=trim(get(77,2,7))

	# get comp info from page or constants?
	compname$=trim(get(25,3,40))
	if compname$="" then \
			compname$="COMP_NAME"; \
			addr1$="COMP_ADDR1"; \
			addr2$="COMP_ADDR2"; \
			addr3$="COMP_ADDR3"; \
			phone$="Phone: COMP_PHONES" \
		else \
			addr1$=trim(get(25,4,46)); \
			addr2$=trim(get(25,5,46)); \
			addr3$=trim(get(25,6,46)); \
			phone$=trim(get(25,7,46)); \
			if phone$="" then if addr3$="" or \
					addr3$(1,1)>="A" then \
					phone$="Phone: COMP_PHONES" \
				else \
					phone$="Phone: "+addr3$,addr3$="" \
				else 	phone$="Phone: "+phone$
	if addr3$="" then addr3$=phone$,phone$=""

	invno$=trim(get(78,3,6))
	invpage$=trim(get(82,5,3))
	invdate$=trim(get(76,7,8))
	to_whse$=trim(get(16,10,15))
	from_whse$=trim(get(65,10,15))

	# find/mark memo lines
	desc_pos=pos("DESCRIPTION"=text$[20])
	for i=22 to 61
		if trim(text$[i](2,desc_pos-3))="" then \
			text$[i](desc_pos-3,2)="mL"
	next i
}

# erase columns !
cerase 1,1,1,MAXROWS
cerase 85,1,85,MAXROWS

# erase rows - or =
cerase 1,1,MAXCOLS,1
cerase 1,15,MAXCOLS,15
cerase 1,17,MAXCOLS,17
cerase 1,19,MAXCOLS,19
cerase 1,21,MAXCOLS,21
cerase 1,62,MAXCOLS,62
cerase 1,65,MAXCOLS,65
cerase 1,MAXROWS,MAXCOLS,MAXROWS

# default line enhancements
const XMASK=(DESCRIPTION)|(Description)@2,20,40,20
cfont "~XMASK",-2,2,2,61,DBFONT,ITEM_JUSTIFY 		# item
cfont "~XMASK",0,2,42,61,DFONT				# desc
cfont 44,22,52,61,DBRFONT					# ordered
cfont 54,22,59,61,DBRFONT					# ship
cfont 61,22,65,61,DBRFONT					# back
cfont 67,22,68,61,DBCFONT					# uom
cfont 70,22,77,61,DBRFONT					# wt
cfont 79,22,MAXRCOLS,61,DSBRFONT				# loc

# header
cerase 1,1,MAXCOLS,10
cbox LEFTCOL,1,MAXCOLS,MAXROWS,MBOXSIZE
cbox LEFTCOL,1,MAXCOLS,10,MBOXSIZE
LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
text 1,2,{title$},HBRFONT,16,cols=MAXRCOLS
text 1,3,{invreprint$},HRFONT,12,cols=MAXRCOLS
text 1,2,{compname$},HBCFONT,14,cols=MAXRCOLS
text 1,3.2,{addr1$},HCFONT,12,cols=MAXRCOLS
text 1,4.3,{addr2$},HCFONT,12,cols=MAXRCOLS
text 1,5.4,{addr3$},HCFONT,12,cols=MAXRCOLS
text 1,6.5,{phone$},HCFONT,12,cols=MAXRCOLS
text 1,7.5,"COMP_EMAIL",HCFONT,cols=MAXRCOLS
text 1,8.5,"COMP_WEBSITE",HCFONT,cols=MAXRCOLS
cbox 64,3.75,MAXCOLS,5,1,100
if copy WAREHOUSE_COPY
	text 65,4.5,"Warehouse Copy",HBCFONT,12,cols=20,shade 0
end if
if copy FILE_COPY
	text 65,4.5,"File Copy",HBCFONT,12,cols=20,shade 0
end if

# right header
cbox 64,5.5,MAXCOLS,10
cbox 64,5.5,72,10,1,ISHADE
cbox 64,7,MAXCOLS,8.5
text 65,6.25,"Number",IFONT
text 65,7.75,"Date",IFONT
text 65,9.25,"Page",IFONT
text 73,6.25,{invno$},DBFONT
text 73,7.75,{invdate$},DBFONT
text 73,9.25,{invpage$},DBFONT

# to whse section
cerase 1,10,MAXCOLS,10
cbox LEFTCOL,10,MAXCOLS,15,MBOXSIZE
cbox LEFTCOL,10,6,15,1,ISHADE
text 2,11,"To",IFONT
text 2,12,"Whse:",IFONT
text 2,13,{to_whse$},DBFONT
cfont 7,11,41,14,DBFONT				# to whse addr

# ship to section
cbox 47,10,53,15,1,ISHADE
text 48,11,"From",IFONT
text 48,12,"Whse:",IFONT
text 48,13,{from_whse$},DBFONT
cfont 54,11,MAXCOLS,14,DBFONT			# from whse addr

# ribbon section
cerase 17,16,17,18
cerase 26,16,26,18
cerase 36,16,36,18
cerase 69,16,69,18
cbox LEFTCOL,15,MAXCOLS,19,MBOXSIZE
cbox LEFTCOL,15,MAXCOLS,17,1,ISHADE
cbox 17,15,26,19
cbox 36,15,69,19
cfont 2,16,16,16,IFONT,proper					# ref #
cfont 18,16,25,16,ICFONT,proper				# ordered dt
cfont 27,16,35,16,ICFONT,proper				# requested dt
cfont 70,16,MAXCOLS,16,IFONT,proper				# ship via
cfont 2,18,16,18,DBFONT						# ref #
cfont 18,18,25,18,DBCFONT					# ordered dt
cfont 27,18,35,18,DBCFONT					# requested dt
cfont 70,18,MAXCOLS,18,DBFONT					# ship via

# detail
erase "~XMASK",-1,0,1,42
erase "!@43,20,43,61",0,0,1,1
erase "!@53,20,53,61",0,0,1,1
erase "!@60,20,60,61",0,0,1,1
erase "!@66,20,66,61",0,0,1,1
erase "!@69,20,69,61",0,0,1,1
erase "!@78,20,78,61",0,0,1,1
cbox LEFTCOL,19,MAXCOLS,62,MBOXSIZE
cbox LEFTCOL,19,MAXCOLS,21,1,DSHADE
box "~XMASK",-1,-1,1,43
cbox 46,19,53,62
cbox 60,19,66,62
cbox 69,19,78,62

cfont "~XMASK",-2,0,2,20,IFONT,ITEM_JUSTIFY,proper	# item cd
cfont "~XMASK",0,0,42,20,IFONT,proper			# desc
cfont 44,20,52,20,IRFONT,proper				# ordered
cfont 54,20,59,20,IRFONT,proper				# ship
cfont 61,20,65,20,IRFONT,proper				# back
cfont 67,20,68,20,ICFONT					# uom
cfont 70,20,77,20,IRFONT,proper				# wt
cfont 79,20,MAXRCOLS,20,IRFONT,proper			# loc

# handle memo lines
font "mL@2,22,25,61",3,0,40,1,DFONT				# memo lns
erase "mL@2,22,40,61",0,0,2,1					# spc chars

# handle alternate location lines
font "Alt Loc: ",0,0,8,1,DFONT				# title
font "Alt Loc: ",9,0,60,1,DSBFONT				# alt locs

# footer
cbox LEFTCOL,62,MAXCOLS,MAXROWS,MBOXSIZE
box "Total Weight",-2,-1,16,2,1,HSHADE
box "Total Weight",14,-1,9,2
font "TOTAL WEIGHT",0,0,14,1,IBRFONT,10,PROPER		# title
font "Total Weight",15,0,8,1,DBRFONT,10			# tot wt
font "CONTINUED",0,0,9,1,IBRFONT,proper

cfont 2,63,53,645,DFONT
cfont 2,65,MAXCOLS,65,DFONT

[S/O Counter]
# Counter Control	1-66, 2-N, 3-S/I, 4-0, 5-1/2/B
detect 0,2,"INVOICE"
detect 0,16,"CHECK/CARD#"

# document options
const MAXCOLS=80
const MAXRCOLS=79
const LEFTCOL=1
const MAXROWS=66
cols MAXCOLS
page MAXROWS
rows MAXROWS

const CUSTOMER_COPY=1
const FILE_COPY=2
pcopies 2

prepage {
	#get header info for better placement
	title$=trim(get(38,2,7))
	# get comp info from page or constants?
	compname$=trim(get(20,3,40))
	if compname$="" then \
			compname$="COMP_NAME"; \
			addr1$="COMP_ADDR1"; \
			addr2$="COMP_ADDR2"; \
			addr3$="COMP_ADDR3"; \
			phone$="Phone: COMP_PHONES" \
		else \
			addr1$=trim(get(20,4,46)); \
			addr2$=trim(get(20,5,46)); \
			addr3$=trim(get(20,6,46)); \
			phone$=trim(get(20,7,46)); \
			if phone$="" then if addr3$="" or \
					addr3$(1,1)>="A" then \
					phone$="Phone: COMP_PHONES" \
				else \
					phone$="Phone: "+addr3$,addr3$="" \
				else 	phone$="Phone: "+phone$
	if addr3$="" then addr3$=phone$,phone$=""

	invno$=trim(get(71,10,8))
	invpage$=trim(get(71,12,8))
	invdate$=trim(get(71,14,8))
	cust_code$=trim(get(14,10,25))

	# search for bottom of vertical lines in detail area
	# prepayment area should not have any vertical lines
	# detail lines will have many !, prepayment only 2 !
	desc_pos=pos("DESCRIPTION"=text$[20])
	detail_bottom=60
	equal$=FILL_CMD(79,"=")
	for i=22 to detail_bottom-1
		if pos(equal$=text$[i])=2 then \
			detail_bottom=i;break
		x=pos("!"=text$[i],1,0)		# get # of !
		if x=2 then detail_bottom=i-1; break
	next i

	if detail_bottom<=22 then goto draw_no_detail_lines
	x$=set(1,detail_bottom,100,"")
	if detail_bottom<60 then \
		x$="cbox LEFTCOL,21,MAXCOLS,"+str(detail_bottom)
		exec(x$)
	# draw vertical lines
	x$="cbox "+str(desc_pos-1)+",19,"+str(desc_pos-1)+","+ \
		str(detail_bottom)
	exec(x$)
	x$="cbox 43,19,43,"+str(detail_bottom)
	exec(x$)
	x$="cbox 53,19,56,"+str(detail_bottom)
	exec(x$)
	x$="cbox 66,19,69,"+str(detail_bottom)
	exec(x$)
draw_no_detail_lines:

	# find memo lines and mark them for enhancing later
	if detail_bottom<=21 then goto no_memo_lines
	serial_on=0
	for i=22 to detail_bottom-1
		# if ! exists: remove it
		if text$[i](desc_pos-1,1)="!" then \
			text$[i](desc_pos-1,1)=" "
		if text$[i](43,1)="!" then text$[i](43,1)=" "
		if text$[i](53,1)="!" then text$[i](53,1)=" "
		if text$[i](56,1)="!" then text$[i](56,1)=" "
		if text$[i](66,1)="!" then text$[i](66,1)=" "
		if text$[i](69,1)="!" then text$[i](69,1)=" "
		# if item # exists; must be item line
		if trim(text$[i](2,desc_pos-3))<>"" then \
			serial_on=0;continue
		# is it a blank line?
		if trim(text$[i](desc_pos,20))="" then continue
		# is it a serial # line
		if text$[i](desc_pos,5)="Ser# " or \
			text$[i](desc_pos,5)="Lot# " then \
			text$[i](desc_pos-3,2)="sL"; \
			serial_on=1; continue
		if text$[i](desc_pos,5)="     " and serial_on then \
			text$[i](desc_pos-3,2)="sL"; \
			continue
		# must be memo line or 2nd desc line
		text$[i](desc_pos-3,2)="mL"; serial_on=0
	next i
no_memo_lines:

	# mark prepayment lines for later enhancing
	if detail_bottom>=60 then goto no_prepayment_lines
	for i=detail_bottom+1 to 59
		if pos("-----"=text$[i]) then text$[i]=""; \
			exec("cbox 15,"+str(i)+",42,"+str(i));continue
		if text$[i](15,1)<>"" then text$[i](13,2)="pL"
	next i
no_prepayment_lines:
}

# erase columns !
cerase 1,1,1,MAXROWS
cerase 80,1,80,MAXROWS

# erase rows - or =
cerase 1,1,MAXCOLS,1
cerase 1,15,MAXCOLS,15
cerase 1,17,MAXCOLS,17
cerase 1,19,MAXCOLS,19
cerase 1,21,MAXCOLS,21
cerase 1,60,MAXCOLS,60
cerase 1,MAXROWS,MAXCOLS,MAXROWS
hline "^^"

# header
cerase 1,1,MAXCOLS,10
cbox LEFTCOL,1,MAXCOLS,MAXROWS,MBOXSIZE
cbox LEFTCOL,1,MAXCOLS,10,MBOXSIZE
LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
text 1,2,{title$},HBRFONT,16,cols=MAXRCOLS
text 1,2,{compname$},HBCFONT,14,cols=MAXRCOLS
text 1,3.2,{addr1$},HCFONT,12,cols=MAXRCOLS
text 1,4.3,{addr2$},HCFONT,12,cols=MAXRCOLS
text 1,5.4,{addr3$},HCFONT,12,cols=MAXRCOLS
text 1,6.5,{phone$},HCFONT,12,cols=MAXRCOLS
text 1,7.5,"COMP_EMAIL",HCFONT,cols=MAXRCOLS
text 1,8.5,"COMP_WEBSITE",HCFONT,cols=MAXRCOLS
if copy CUSTOMER_COPY
	text 65,4.5,"Customer Copy",HBCFONT,12,cols=15,shade 0
end if
if copy FILE_COPY
	text 65,4.5,"File Copy",HBCFONT,12,cols=15,shade 0
end if

# right header
cerase 60,10,MAXCOLS,15
cbox 64,3.75,MAXCOLS,5.25,1,100
cbox 64,5.5,MAXCOLS,10
cbox 64,5.5,72,10,1,ISHADE
cbox 64,7,MAXCOLS,8.5
text 65,6.25,"Number",IFONT
text 65,7.75,"Page",IFONT
text 65,9.25,"Date",IFONT
text 73,6.25,{invno$},DBFONT
text 73,7.75,{invpage$},DBFONT
text 73,9.25,{invdate$},DBFONT

# sold to section
cbox LEFTCOL,10,MAXCOLS,15,MBOXSIZE
cbox LEFTCOL,10,10,15,1,ISHADE
text 2,11,"Sold To:",IFONT
text 2,12,{cust_code$},DSBFONT
cmove 6,11,41,14,11,11
cfont 11,11,41,14,DBFONT				# sold to addr

# ribbon 1 section
cerase 69,16,75,16
cerase 6,15,6,19
cerase 22,15,22,19
cerase 43,15,43,19
cerase 49,15,49,19
cerase 52,15,52,19
cerase 68,15,68,19
cbox LEFTCOL,15,MAXCOLS,19,MBOXSIZE
cbox LEFTCOL,15,MAXCOLS,17,1,ISHADE
cbox 6,15,22,19
cbox 43,15,49,19
cbox 52,15,68,19
cfont 1,16,5,16,ICFONT				# salesperson
cfont 7,16,21,16,IFONT				# terms
cfont 23,16,42,16,IFONT				# check/card #
cfont 44,16,48,16,IRFONT			# tax %
cfont 50,16,51,16,ICFONT			# whs
cfont 53,16,67,16,IFONT				# ref #
text 69,16,"RECEIPT #",IFONT			# receipt #

cfont 1,18,5,18,DBCFONT				# salesperson
cfont 7,18,21,18,DBFONT				# terms
cfont 23,18,42,18,DBFONT			# check/card #
cfont 44,18,48,18,DBRFONT			# tax %
cfont 50,18,51,18,DBCFONT			# whs
cfont 53,18,67,18,DBFONT			# ref #
cfont 69,18,MAXRCOLS,18,DBFONT		# receipt #

# detail
erase "DESCRIPTION@1,20,40,20",-1,0,1,1
cerase 43,20,43,20
cerase 53,20,53,20
cerase 56,20,56,20
cerase 66,20,66,20
cerase 69,20,69,20
cbox LEFTCOL,19,MAXCOLS,60,MBOXSIZE
cbox LEFTCOL,19,MAXCOLS,21,1,DSHADE

const XMASK=DESCRIPTION@2,20,40,20
cfont "XMASK",-2,0,2,20,IFONT,ITEM_JUSTIFY	# item
cfont "XMASK",0,0,43,20,IFONT				# desc
cfont 44,20,52,20,IRFONT				# quantity
cfont 54,20,55,20,ICFONT				# uom
cfont 57,20,65,20,IRFONT				# price
cfont 67,20,68,20,ICFONT				# uom
cfont 70,20,MAXRCOLS,20,ICFONT			# extension

SO_INV_CFONT "XMASK",-2,2,2,60,DBFONT,ITEM_JUSTIFY # item
SO_INV_CFONT "XMASK",0,2,43,60,DFONT		# desc
SO_INV_CFONT 44,22,52,60,DBRFONT			# quantity
SO_INV_CFONT 54,22,55,60,DBRFONT			# uom
SO_INV_CFONT 57,22,65,60,DBRFONT			# price
SO_INV_CFONT 67,22,68,60,DBCFONT			# uom
SO_INV_CFONT 70,22,MAXRCOLS,60,DBPFONT		# extension
# enhance memo lines
SO_INV_FONT "mL@2,22,25,59",3,0,40,1,DFONT	# memo lines
erase "mL@2,22,40,59",0,0,2,1				# spec chars
# enhance serial # lines
SO_INV_FONT "sL@2,22,25,59",3,0,4,1,DFONT		# serial lines
SO_INV_FONT "sL@2,22,25,59",8,0,40,1,DFONT	# serial lines
erase "sL@2,22,40,59",0,0,2,1				# spec chars
# handle payment info
SO_INV_FONT "pL@13,22,14,59",2,0,14,1,DFONT	# pymt desc
SO_INV_FONT "pL@13,22,14,59",17,0,13,1,DBPFONT	# pymt amts
SO_INV_FONT "pL@13,22,14,59",31,0,25,1,DFONT	# pymt comment
erase "pL@13,22,14,59",0,0,2,1			# spec chars

# footer
cerase 23,60,MAXCOLS,60
cerase 23,62,MAXCOLS,62
cerase 23,64,MAXCOLS,64
cerase 23,60,23,64
cerase 36,60,36,63
cerase 46,60,46,63
cerase 57,60,57,63
cerase 68,60,68,63
cbox LEFTCOL,60,MAXCOLS,MAXROWS,MBOXSIZE
cbox 23,60,MAXCOLS,62,1,HSHADE
cbox 23,62,MAXCOLS,64
cbox 36,60,46,64
cbox 57,60,68,64
cfont 24,61,35,61,IBRFONT			# merchandise
cfont 37,61,45,61,IBRFONT			# tax
cfont 47,61,56,61,IBRFONT			# tendered
cfont 58,61,67,61,IBRFONT			# cash back
cfont 69,61,MAXRCOLS,61,IBRFONT,10		# tot due

cfont 24,63,35,63,DBRFONT			# merchandise
cfont 37,63,45,63,DBRFONT			# tax
cfont 47,63,56,63,DBRFONT			# tendered
cfont 58,63,67,63,DBRFONT			# cash back
cfont 69,63,MAXRCOLS,63,DBRFONT,10		# tot due

cfont 2,61,23,64,DFONT
cfont 2,65,MAXCOLS,65,DFONT

[A/P Check]
# Print Control	1-01, 2-21, 3-55, 4-45, 5-55, 6-11, 7-68, 8-13
detect 41,5,"~DATEMASK.."
detect 60,5,"~[0-9][0-9][0-9][0-9][0-9][0-9]"	# Check #

# document options
const MAXCOLS=83
const MAXRCOLS=82
const MAXROWS=66
cols MAXCOLS
page 42
rows MAXROWS

const ONE_STUB_COPY=1
const TWO_STUB_COPY=2
pcopies 2

prepage {
	# the following moves will leave a space between 
	# the top two stubs
	# move check to bottom
	for i=23 to 42
      	text$[i+24]=text$[i]
		text$[i]=""			# clear line
	next i

	# copy stub from top to middle
	for i=1 to 22
       	text$[i+24]=text$[i]
	next i

	chkno$=trim(get(60,5,6))
	chk_amt_words$=trim(get(1,56,67))+" "+trim(get(1,57,67))

	# get comp info from constants?
	addr3$="COMP_ADDR3"
	save_addr3$=addr3$
	phone$="Phone: COMP_PHONES"
	if trim(phone$)="Phone:" then phone$=""
	if addr3$="" then addr3$=phone$,phone$="" 
}

precopy {
	if copy=ONE_STUB_COPY and copy<>AP_NO_STUBS then skip=1
	if copy=ONE_STUB_COPY then \
		for i=1 to 21; \
			text$[i]=""; \
		next i
	if copy=TWO_STUB_COPY and copy<>AP_NO_STUBS then skip=1
}

########## Payor Stub (top)

const LEFTCOL=.5
if copy TWO_STUB_COPY
	# top section
	text 2,2,"COMP_NAME",HBFONT
	text 2,2.9,"COMP_ADDR1",HFONT
	text 2,3.8,"COMP_ADDR2",HFONT
	text 2,4.7,{addr3$},HFONT
	text 2,5.6,{phone$},HFONT
	cbox 40,1.5,MAXCOLS,5.5
	cbox 40,1.5,MAXCOLS,2.5,1,ISHADE
	cbox 40,3.5,MAXCOLS,4.5,1,ISHADE
	cbox 53,1.5,53,5.5
	cbox 70,3.5,70,5.5

	text 41,2,"Vendor #",ICFONT,cols=12
	text 54,2,"Vendor Name",IFONT
	cfont 40,3,52,3,DBCFONT				# vendor #
	cfont 54,3,MAXCOLS,3,DBFONT			# vendor name
	
	text 41,4,"Check Date",ICFONT,cols=12
	text 54,4,"Check #",ICFONT,cols=16
	text 71,4,"Page #",ICFONT,cols=12
	cfont 41,5,52,5,DBCFONT				# check dt
	cfont 54,5,69,5,DBCFONT				# check #
	cfont 71,5,MAXCOLS,5,DBCFONT			# page #

	# detail
	cbox LEFTCOL,6.5,MAXCOLS,7.5,1,DSHADE
	cbox LEFTCOL,7.5,MAXCOLS,20.5
	cbox 11,6.5,11,20.5
	cbox 22,6.5,22,20.5
	cbox 34,6.5,34,20.5
	cbox 46,6.5,46,20.5
	cbox 58,6.5,58,20.5
	text 1,7,"Inv Date",ICFONT,cols=10
	text 12,7,"Invoice #",IRFONT,cols=10
	text 23,7,"Amount",IRFONT,cols=10
	text 35,7,"Discount",IRFONT,cols=10
	text 47,7,"Amount Paid",IRFONT,cols=10
	text 59,7,"Memo",IFONT
	cfont 1,8,10,20,DBCFONT				# inv dt
	cfont 12,8,21,20,DBRFONT			# inv #
	cfont 23,8,33,20,DBPFONT			# inv amt
	cfont 35,8,45,20,DBPFONT			# discount
	cfont 47,8,57,20,DBPFONT			# paid amt
	cfont 59,8,MAXCOLS,20,IFONT			# memo

	# footer
	cbox 11,20.5,58,21.5
	cbox 11,20.5,22,21.5,1,100
	cbox 34,20.5,34,21.5
	cbox 46,20.5,46,21.5
	text 12,21,"Totals",IBFONT,shade 0
	cfont 23,21,33,21,DBPFONT			# inv amt
	cfont 35,21,45,21,DBPFONT			# discount
	cfont 47,21,57,21,DBPFONT			# paid amt

	text 1,21.5,"Payor's Copy",IBRFONT,cols=MAXRCOLS
	cbox LEFTCOL,23.5,MAXCOLS,23.5
endif

########### Vendor Stub
# top section
text 2,26,"COMP_NAME",HBFONT
text 2,26.9,"COMP_ADDR1",HFONT
text 2,27.8,"COMP_ADDR2",HFONT
text 2,28.7,{ADDR3$},HFONT
text 2,29.6,{phone$},HFONT
cbox 40,25.5,MAXCOLS,29.5
cbox 40,25.5,MAXCOLS,26.5,1,ISHADE
cbox 40,27.5,MAXCOLS,28.5,1,ISHADE
cbox 53,25.5,53,29.5
cbox 70,27.5,70,29.5

text 41,26,"Vendor #",ICFONT,cols=12
text 54,26,"Vendor Name",IFONT
cfont 40,27,52,27,DBCFONT				# vendor #
cfont 54,27,MAXCOLS,27,DBFONT				# vendor name

text 41,28,"Check Date",ICFONT,cols=12
text 54,28,"Check #",ICFONT,cols=16
text 71,28,"Page #",ICFONT,cols=12
cfont 41,29,52,29,DBCFONT				# check dt
cfont 54,29,69,29,DBCFONT				# check #
cfont 71,29,MAXCOLS,29,DBCFONT			# page #

# detail
cbox LEFTCOL,30.5,MAXCOLS,31.5,1,DSHADE
cbox LEFTCOL,31.5,MAXCOLS,44.5
cbox 11,30.5,11,44.5
cbox 22,30.5,22,44.5
cbox 34,30.5,34,44.5
cbox 46,30.5,46,44.5
cbox 58,30.5,58,44.5
text 1,31,"Inv Date",ICFONT,cols=10
text 12,31,"Invoice #",IRFONT,cols=10
text 23,31,"Amount",IRFONT,cols=10
text 35,31,"Discount",IRFONT,cols=10
text 47,31,"Amount Paid",IRFONT,cols=10
text 59,31,"Memo",IFONT
cfont 1,32,10,44,DBCFONT				# inv dt
cfont 12,32,21,44,DBRFONT				# inv #
cfont 23,32,33,44,DBPFONT				# inv amt
cfont 35,32,45,44,DBPFONT				# discount
cfont 47,32,57,44,DBPFONT				# paid amt
cfont 59,32,MAXCOLS,44,IFONT				# memo

# footer
cbox 11,44.5,58,45.5
cbox 11,44.5,22,45.5,1,100
cbox 34,44.5,34,45.5
cbox 46,44.5,46,45.5
text 12,45,"Totals",IBFONT,shade 0
cfont 23,45,33,45,DBPFONT				# inv amt
cfont 35,45,45,45,DBPFONT				# discount
cfont 47,45,57,45,DBPFONT				# paid amt

text 1,45.5,"Vendor's Copy",IBRFONT,cols=MAXRCOLS
cbox LEFTCOL,46.5,MAXCOLS,46.5

########### Check

cbox LEFTCOL,47,MAXCOLS,64.5,4,HSHADE
LOGO_IMAGE 1,47,10,5,"COMP_LOGO"
text 15,48.25,"COMP_NAME",HBFONT,14
text 15,49.35,"COMP_ADDR1",HFONT,12
text 15,50.35,"COMP_ADDR2",HFONT,12
text 15,51.35,"COMP_ADDR3",HFONT,12
text 70,49.35,"AP_ROUTING",DFONT		# rtg#
text 49,48.25,"AP_BANK_NAME",DBFONT
text 49,49.05,"AP_BANK_ADDR1",DFONT
text 49,49.85,"AP_BANK_ADDR2",DFONT

cmove 44,52,63,52,49,52
cbox 48,50.5,81,51.5,1,100
cbox 48,51.5,81,52.5
cbox 57,50.5,69,52.5
text 49,51,"Check #",ICFONT,shade 0,cols=8
cfont 49,52,56,52,DBCFONT				# chk #
text 58,51,"Date",ICFONT,shade 0,cols=11
cfont 58,52,68,52,DBCFONT				# chk dt
cmove 69,56,79,56,70,52					# chk amt
text 70,51,"Amount",IRFONT,shade 0,cols=11
cfont 70,52,80,52,DBRFONT				# chk amt

cerase 1,56,MAXCOLS,57
text 2,56,"Pay",IFONT,14
text 6.5,56,{chk_amt_words$},IBFONT

cmove 14,60,43,64,9,60
text 2,60,"Pay",IFONT
text 2,61,"to the",IFONT
text 2,62,"Order",IFONT
text 2,63,"of",IFONT
cfont 9,60,MAXCOLS,63,DBFONT

text 50,59.50,"Check Void After 180 Days",ICFONT,cols=30
SIGNATURE_IMAGE 50,61,0,0,"SIGNATURE"
box 50,62.0,30,1,3
text 50,62.75,"Authorized Signature",ICFONT,cols=30
AP_MICR 10,65.50,"AP_MICR_ACCOUNTNO",{chkno$}

[A/P Vouchers]
detect 0,2,"CHECK VOUCHER"

# document options
const MAXCOLS=80
const MAXRCOLS=79
const MAXROWS=66
const LEFTCOL=.5
cols MAXCOLS
rows MAXROWS

prepage {
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	pgmname$=trim(get(75,1,6))
	compname$=trim(get(16,1,50))

	# load row 2 variables
	title$=trim(get(1,2,MAXCOLS))
}

# default line enhancements
cfont 1,1,8,MAXROWS,DCFONT				# date
cfont 10,1,19,MAXROWS,DRFONT				# inv #
cfont 21,1,30,MAXROWS,DBRFONT				# amt
cfont 32,1,41,MAXROWS,DBRFONT				# disc
cfont 43,1,52,MAXROWS,DBRFONT				# paid amt
cfont 54,1,MAXCOLS,MAXROWS,DFONT			# comments

# header
cerase 1,1,MAXCOLS,2
cbox LEFTCOL,.5,MAXCOLS,2.75,MBOXSIZE,HSHADE
text 2,1.25,{rptdate$},HBFONT
text 1,1.25,{compname$},HBCFONT,14,cols=MAXCOLS
text 1,1.25,{pgmname$},HBRFONT,cols=MAXRCOLS
text 1,2.25,{title$},HBCFONT,12,cols=MAXCOLS

# ribbon info
cfont 1,4,6,4,IFONT					# check # title
cfont 8,4,13,4,DBFONT					# check #
cfont 16,4,22,4,IFONT					# vendor
cfont 24,4,MAXCOLS,4,DBFONT				# name & code

# detail headings
cerase 1,7,MAXCOLS,7
cbox LEFTCOL,5.5,MAXCOLS,6.5,1,DSHADE
cfont 1,6,8,6,ICFONT					# date
cfont 10,6,19,6,IRFONT					# inv #
cfont 21,6,30,6,IRFONT					# amt
cfont 32,6,41,6,IRFONT					# disc
cfont 43,6,52,6,IRFONT					# paid amt
cfont 54,6,MAXCOLS,6,IFONT				# comments

# footer
hline "---",erase
box "   ---------",2,0.5,33,1.01,1,HSHADE

[P/R Check - long stub]
# Check Control	01-01, 02-42, 03-03, 04-16, 05-51, 06-64, 07-75,
#			08-01, 09-18, 10-25, 11-36, 12-48, 13-61, 14-72,
#			15-21, 16-90, 17-66, 18-66, 19-07, 20-66, 21-12

detect  51,2,"~ [0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]"
detect  66,49,"~ [0-1][0-9]/[0-3][0-9]/[0-9][0-9]"       # dt

# document options
const MAXCOLS=83
const MAXRCOLS=84
const MAXROWS=66
cols MAXCOLS
page 63
rows MAXROWS

prepage {
	chk_date$=trim(get(67,49,8))
	# if stub date is missing, place check date there
	if trim(get(65,2,8))="" then \
		x$=set(65,2,8,chk_date$)

	chkno$=trim(get(65,47,15))
	chk_amt_words$=trim(get(8,51,58))
	chk_amt$=trim(get(67,51,11))
}

# stub
# header
text 2,1.25,"COMP_NAME",HBFONT,14
text 35,1.25,"COMP_ADDR1",HBFONT,12
text 55,1.25,"COMP_ADDR2",HBFONT,12	

# ribbon
move 1,1,84,41,1,2                        # dn 1 row
cbox 1,1.5,MAXCOLS,3.5,MBOXSIZE		# data
cbox 1,1.5,MAXCOLS,2.5,1,ISHADE		# labels
cbox 16,1.5,50,3.5                        # separators
cbox 64,1.5,74,3.5                        # separators
text 2,2,"Dept",ICFONT,cols=13   		# Dept
text 17,2,"Employee name",IFONT		# Empl name
text 51,2,"Social Security #",ICFONT,cols=13 # SSN
text 65,2,"Date",ICFONT,cols=9		# dt
text 75,2,"Check #",ICFONT,cols=8		# Check #
cfont 2,3,14,3,DBCFONT				# Department
cfont 17,3,49,3,DBFONT		            # Empl name
cfont 51,3,63,3,DBCFONT				# SSN
cfont 65,3,73,3,DBCFONT				# dt
cfont 75,3,82,3,DBCFONT				# check #
	
# detail
cbox 1,3.5,MAXCOLS,40.5,MBOXSIZE          # detail
cbox 1,3.5,MAXCOLS,4.5,1,DSHADE		# labels
cbox 19,3.5,26,40.5                       # separators
cbox 37,3.5,37,40.5                       # separators
cbox 48,3.5,48,40.5,3                     # separators
cbox 62,3.5,73,40.5                       # separators
text 2,4,"Description",IFONT,cols=16	# desc
text 20,4,"Hours",IRFONT,cols=6		# hours
text 27,4,"Gross",IRFONT,cols=10		# gross
text 38,4,"YTD Gross",IRFONT,cols=10	# ytd gross
text 49,4,"Deductions",IFONT			# deductions
text 63,4,"Deduct",IRFONT,cols=10		# deduct
text 74,4,"Gross ded",IRFONT,cols=9		# gross deduct
cfont 2,5,18,40,IFONT				# desc
cfont 20,5,25,40,DBRFONT			# hours
cfont 27,5,36,40,DBRFONT			# gross
cfont 38,5,47,40,DBRFONT			# ytd gross
cfont 49,5,61,40,IFONT				# deductions
cfont 63,5,72,40,DBRFONT			# deduct
cfont 74,5,82,40,DBRFONT			# gross ded

# footer
cbox 1,40.5,26,42.5,1,100                 # tot labels
cbox 26,40.5,48,42.5                      # tots
cbox 37,40.5,37,42.5                      # tots
cbox 62,40.5,MAXCOLS,42.5                 # separators
cbox 73,40.5,73,42.5                      # separators
text 2,41,"Gross totals",IBFONT,shade 0
text 2,42,"Net totals",IBFONT,shade 0
cfont 27,41,35,42,DBRFONT			# gross
cfont 37,41,47,42,DBRFONT			# ytd gross
cfont 63,41,72,42,DBRFONT			# deduct
cfont 74,41,82,42,DBRFONT			# gross ded

# check
# header
cbox 1,46,83,64.5,1,ISHADE					# check
LOGO_IMAGE 1,47,10,5,"COMP_LOGO"
text 15,48.25,"COMP_NAME",HBFONT,14
text 15,49.35,"COMP_ADDR1",HFONT,12
text 15,50.35,"COMP_ADDR2",HFONT,12
text 15,51.35,"COMP_ADDR3",HFONT,12
text 70,49.35,"PR_ROUTING",DFONT			# rtg#
text 49,48.25,"PR_BANK_NAME",DBFONT
text 49,49.05,"PR_BANK_ADDR1",DFONT
text 49,49.85,"PR_BANK_ADDR2",DFONT

# ribbon
cerase 1,47,84,51
cbox 48,50.5,81,51.5,1,100				# labels
cbox 48,51.5,81,52.5					# data
cbox 57,51.5,69,52.5					# separator
text 49,51,"Check #",ICFONT,shade 0,cols=8
text 58,51,"Date",ICFONT,shade 0,cols=11
text 70,51,"Amount",IRFONT,shade 0,cols=11
text 49,52,{chkno$},DBCFONT,cols=8
text 58,52,{chk_date$},DBCFONT,cols=11
text 70,52,{chk_amt$},DBRFONT,cols=11

# check amt in words
cerase 2,51,MAXCOLS,51					# amt in words
text 2,56,"Pay",HFONT,14
text 7,56,{chk_amt_words$},IBFONT

# pay to
cmove 13,55,47,58,9,60					# payee and addr
text 2,60,"Pay",HFONT
text 2,61,"to the",HFONT
text 2,62,"Order",HFONT
text 2,63,"of",HFONT
cfont 9,60,MAXCOLS,63,DBFONT				# payee and addr

# Bottom
text 48,59.5,"Check Void After 180 Days",ICFONT,cols=30
SIGNATURE_IMAGE 50,61,0,0,"SIGNATURE"
box 47,62.0,30,1,3					# signature line
text 47,62.75,"Authorized Signature",ICFONT,cols=30
PR_MICR 10,65.5,"PR_MICR_ACCOUNTNO",{chkno$}

[P/R Check - short stub - 1/2]
# new rule set - 06/15/01
# Check Control	01-01, 02-21, 03-03, 04-16, 05-51, 06-64, 07-75,
#			08-01, 09-18, 10-25, 11-36, 12-48, 13-61, 14-72,
#			15-21, 16-90, 17-66, 18-66, 19-07, 20-66, 21-12

detect  51,2,"~ [0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]"
detect  66,28,"~ [0-1][0-9]/[0-3][0-9]/[0-9][0-9]"       # dt

# document options
const MAXCOLS=83
const MAXRCOLS=82
const MAXROWS=66
cols MAXCOLS
page 42
rows MAXROWS

const ONE_STUB_COPY=1
const TWO_STUB_COPY=2
pcopies 2

prepage {
	chk_date$=trim(get(67,28,8))
	# if stub date is missing, place check date there
	if trim(get(65,2,8))="" then \
		x$=set(65,2,8,chk_date$)

	# the following moves will leave a space between the 
	# top two stubs
	# move check to bottom
	for i=23 to 42
      	text$[i+24]=text$[i]
		text$[i]=""					# clear line
	next i

	# copy stub from top to middle
	for i=1 to 22
       	text$[i+24]=text$[i]
	next i

	chkno$=trim(get(65,50,15))
	chk_amt_words$=trim(get(8,54,58))

}

precopy {
	if copy=ONE_STUB_COPY and copy<>PR_NO_STUBS then skip=1
	if copy=ONE_STUB_COPY then \
		for i=1 to 21; \
			text$[i]=""; \
		next i
	if copy=TWO_STUB_COPY and copy<>PR_NO_STUBS then skip=1
}

#employer stub
if copy TWO_STUB_COPY
	# header
	text 2,2,"COMP_NAME",HBFONT,14
	text 35,2,"COMP_ADDR1",HBFONT,12
	text 55,2,"COMP_ADDR2",HBFONT,12	

	# ribbon
	move 1,1,83,23,1,3                        # dn 2 spcs
	cbox 1,2.5,MAXCOLS,3.5,1,ISHADE           # labels
	cbox 1,3.5,MAXCOLS,4.5                    # data

	cbox 16,2.5,50,4.5                        # separators
	cbox 64,2.5,74,4.5                        # separators
	text 2,3,"Dept",ICFONT,cols=13   		# Dept
	text 17,3,"Employee name",IFONT		# Empl name
	text 51,3,"Social Security #",ICFONT,cols=13 # SSN
	text 65,3,"Date",ICFONT,cols=9		# dt
	text 75,3,"Check #",ICFONT,cols=8		# Check #

	cfont 2,4,14,4,DBCFONT				# Department
	cfont 17,4,49,4,DBFONT		            # Empl name
	cfont 51,4,63,4,DBCFONT				# SSN
	cfont 65,4,73,4,DBCFONT				# dt
	cfont 75,4,82,4,DBCFONT				# check #
	
	# detail
	cbox 1,4.5,MAXCOLS,20.5                   # detail
	cbox 1,4.5,MAXCOLS,5.5,1,DSHADE           # labels
	cbox 18,4.5,27,20.5                       # separators
	cbox 36,4.5,36,20.5                       # separators
	cbox 48,4.5,48,20.5,3                     # separators
	cbox 63,4.5,73,20.5                       # separators
	text 2,5,"Description",IFONT,cols=16	# desc
	text 19,5,"Hours",IRFONT,cols=8		# hours
	text 28,5,"Gross",IRFONT,cols=7		# gross
	text 37,5,"YTD Gross",IRFONT,cols=9		# ytd gross
	text 49,5,"Deductions",IFONT,cols=14	# deductions
	text 64,5,"Deduct",IRFONT,cols=7		# deduct
	text 74,5,"Gross ded",IRFONT,cols=8		# gross deduct

	cfont 2,5,17,20,IFONT				# desc
	cfont 19,5,26,20,DBRFONT			# hours
	cfont 28,5,35,20,DBPFONT			# gross
	cfont 37,5,47,20,DBPFONT			# ytd gross
	cfont 49,5,62,20,IFONT				# deductions
	cfont 64,5,72,20,DBPFONT			# deduct
	cfont 74,5,82,20,DBPFONT			# gross ded

	# footer
	cbox 1,20.5,27,22.5,1,100                 # tot labels
	cbox 27,20.5,48,22.5                      # tots
	cbox 36,20.5,36,22.5                      # tots
	cbox 63,20.5,MAXCOLS,22.5                 # separators
	cbox 73,20.5,73,22.5                      # separators
	text 2,21,"Gross totals",IBFONT,shade 0
	text 2,22,"Net totals",IBFONT,shade 0
	cfont 28,21,35,22,DBPFONT			# gross
	cfont 37,21,47,22,DBPFONT			# ytd gross
	cfont 64,21,72,22,DBPFONT			# deduct
	cfont 74,21,82,22,DBPFONT			# gross ded
endif

# employee stub
# header
text 2,24,"COMP_NAME",HBFONT,14
text 35,24,"COMP_ADDR1",HBFONT,12
text 55,24,"COMP_ADDR2",HBFONT,12	

# ribbon
cbox 1,24.5,MAXCOLS,25.5,1,ISHADE        		# labels
cbox 1,25.5,MAXCOLS,26.5                        # data
cbox 16,24.5,50,26.5                            # separators
cbox 64,24.5,74,26.5					# separators
text 2,25,"Dept",ICFONT,cols=13
text 17,25,"Employee name",IFONT
text 51,25,"Social Security #",ICFONT,cols=13
text 65,25,"Date",ICFONT,cols=9			# dt
text 75,25,"Check #",ICFONT,cols=8

cfont 2,26,14,26,DBCFONT				# Department
cfont 17,26,49,26,DBFONT				# Employee name
cfont 51,26,63,26,DBCFONT				# SS#
cfont 65,26,73,26,DBCFONT				# dt
cfont 75,26,82,26,DBCFONT				# check #

# detail
cbox 1,26.5,MAXCOLS,42.5				# detail
cbox 1,26.5,MAXCOLS,27.5,1,DSHADE			# labels
cbox 18,26.5,27,42.5					# separators
cbox 36,26.5,36,42.5					# separators
cbox 48,26.5,48,42.5,5					# separators
cbox 63,26.5,73,42.5					# separators
text 2,27,"Description",IFONT,cols=16
text 19,27,"Hours",IRFONT,cols=8
text 28,27,"Gross",IRFONT,cols=7
text 37,27,"YTD Gross",IRFONT,cols=9
text 49,27,"Deductions",IFONT,cols=14
text 64,27,"Deduct",IRFONT,cols=7
text 74,27,"Gross ded",IRFONT,cols=8

cfont 2,27,17,45,IFONT					# desc
cfont 19,27,26,45,DBRFONT				# hours
cfont 28,27,35,45,DBPFONT				# gross
cfont 37,27,47,45,DBPFONT				# ytd gross
cfont 49,27,62,45,IFONT					# deductions
cfont 64,27,72,45,DBPFONT				# deduct
cfont 74,27,82,45,DBPFONT				# gross ded

# footer
cbox 1,42.5,27,44.5,1,100				# labels
cbox 27,42.5,48,44.5					# tots
cbox 36,42.5,36,44.5					# separators
cbox 63,42.5,MAXCOLS,44.5				# separators
cbox 73,42.5,73,44.5					# separators
text 2,43,"Gross totals",IBFONT,shade 0
text 2,44,"Net totals",IBFONT,shade 0

cfont 28,27,35,45,DBPFONT				# gross
cfont 37,27,47,45,DBPFONT				# ytd gross
cfont 64,27,72,45,DBPFONT				# deduct
cfont 74,27,82,45,DBPFONT				# gross ded

# check
# header
cbox 1,46,83,64.5,1,ISHADE					# check
LOGO_IMAGE 1,47,10,5,"COMP_LOGO"
text 15,48.25,"COMP_NAME",HBFONT,14
text 15,49.35,"COMP_ADDR1",HFONT,12
text 15,50.35,"COMP_ADDR2",HFONT,12
text 15,51.35,"COMP_ADDR3",HFONT,12
text 70,49.35,"PR_ROUTING",DFONT			# rtg#
text 49,48.25,"PR_BANK_NAME",DBFONT
text 49,49.05,"PR_BANK_ADDR1",DFONT
text 49,49.85,"PR_BANK_ADDR2",DFONT

# ribbon
move 65,50,15,1,49,52					# check #
move 67,52,15,1,58,52					# dt up
move 67,54,15,1,70,52					# numeric $ amt
cbox 48,50.5,81,51.5,1,100				# labels
cbox 48,51.5,81,52.5					# data
cbox 57,51.5,69,52.5					# separator
text 49,51,"Check #",ICFONT,shade 0,cols=8
text 58,51,"Date",ICFONT,shade 0,cols=11
text 70,51,"Amount",IRFONT,shade 0,cols=11

cfont 49,51,56,52,DBCFONT				# check #
cfont 58,51,68,52,DBCFONT				# dt
cfont 70,51,80,52,DBRFONT				# amt 

# check amt in words
cerase 2,54,MAXCOLS,57					# amt in words
text 2,56,"Pay",HFONT,14
text 7,56,{chk_amt_words$},IBFONT

# pay to
cmove 13,58,47,61,9,60					# payee and addr
text 2,60,"Pay",HFONT
text 2,61,"to the",HFONT
text 2,62,"Order",HFONT
text 2,63,"of",HFONT
cfont 9,60,MAXCOLS,63,DBFONT				# payee and addr

# Bottom
text 48,59.5,"Check Void After 180 Days",ICFONT,cols=30
SIGNATURE_IMAGE 50,61,0,0,"SIGNATURE"
box 47,62.0,30,1,3					# signature line
text 47,62.75,"Authorized Signature",ICFONT,cols=30
PR_MICR 10,65.5,"PR_MICR_ACCOUNTNO",{chkno$}

[A/R Dunning letter]
# Dunning Control	1-5, 2-N, 3-D, 4-S, 5-0, 6-0, 7-N, 8-0
detect 0,3,"PAST DUE NOTICE"
detect 0,5,"PAGE"

# document options
const MAXCOLS=80
const MAXRCOLS=79
const MAXROWS=66
cols MAXCOLS
page 66
rows MAXROWS

const CUSTOMER_COPY=1
const FILE_COPY=2
copies 2

prepage {
	# get comp info from page or constants?
	compname$=trim(get(20,5,40))
	if compname$="" then \
			compname$="COMP_NAME"; \
			addr1$="COMP_ADDR1"; \
			addr2$="COMP_ADDR2"; \
			addr3$="COMP_ADDR3"; \
			phone$="Phone: COMP_PHONES" \
		else \
			addr1$=trim(get(20,6,46)); \
			addr2$=trim(get(20,7,46)); \
			addr3$=trim(get(20,8,46)); \
			phone$=trim(get(20,9,46)); \
			if phone$="" then if addr3$="" or \
					addr3$(1,1)>="A" then \
					phone$="Phone: COMP_PHONES" \
				else \
					phone$="Phone: "+addr3$,addr3$="" \
				else 	phone$="Phone: "+phone$
	if addr3$="" then addr3$=phone$,phone$="" 

	pageno$=trim(get(70,5,10))
	to$="To"
	x$=trim(get(20,14,40))
	if x$="NOTICE OF PAST DUE ITEMS" then to$=""
}

# top section
cerase 1,1,MAXCOLS,8
LOGO_IMAGE 1,2,10,5,"COMP_LOGO"
text 1,2,"Past Due Notice",HBCFONT,16,cols=MAXCOLS
text 1,4.1,{compname$},HBCFONT,14,cols=MAXCOLS
text 1,5.2,{addr1$},HCFONT,12,cols=MAXCOLS
text 1,6.3,{addr2$},HCFONT,12,cols=MAXCOLS
text 1,7.4,{addr3$},HCFONT,12,cols=MAXCOLS
text 1,8.5,{phone$},HCFONT,12,cols=MAXCOLS
text 1,9.5,"COMP_EMAIL",HCFONT,cols=MAXRCOLS
text 1,10.5,"COMP_WEBSITE",HCFONT,cols=MAXRCOLS
text 1,4.1,{pageno$},HRFONT,12,cols=MAXRCOLS

# customer name & addr
text 2,15,{to$},IFONT,light
const XMASK=[A-Za-z0-9]@10,15,11,15
font "~XMASK",0,-1,40,5,DBFONT,10
cfont "~XMASK",50,4,MAXRCOLS,19,DBRFONT 		# dt

# letter text
cfont "~XMASK",-3,6,MAXCOLS,37,IFONT

# new headers
font "NOTICE OF PAST DUE ITEMS",0,0,24,1,IBFONT
font "NOTICE OF PAST DUE ITEMS",-13,2,10,1,IRFONT
font "NOTICE OF PAST DUE ITEMS",4,2,4,1,ICFONT,cols=8
font "NOTICE OF PAST DUE ITEMS",12,2,9,1,ICFONT,cols=9
font "NOTICE OF PAST DUE ITEMS",28,2,6,1,IFONT
cfont "~DATEMASK@31,18,39,51",-15,0,24,54,DBRFONT	# inv no
cfont "~DATEMASK@31,18,39,51",0,0,38,54,DBCFONT		# dt
cfont "~DATEMASK@31,18,39,51",10,0,49,54,DBCFONT	# dys past
cfont "~DATEMASK@31,18,39,51",20,0,62,54,DBPFONT	# amt

# footer
font "BALANCE@1,52",-1,-1,8,2,IBCFONT
font "PAST DUE@1,52",0,-1,8,2,IBCFONT
font "BALANCE@1,52",-4,2,11,1,DBPFONT
font "PAST DUE@1,52",-3,2,11,1,DBPFONT
if copy CUSTOMER_COPY
	text 1,65,"Customer Copy",HBCFONT,12,cols=MAXCOLS
endif
if copy FILE_COPY
	text 1,65,"File Copy",HBCFONT,12,cols=MAXCOLS
endif

[J/C Estimate]
# Handles with and without cost tearoff
# Static Control	9-66, 10-N, 11-Y/N
detect 0,2,"ESTIMATE"
detect 0,7,"~DATEMASK"

# document options
const MAXCOLS=80
const MAXRCOLS=79
const LEFTCOL=1
const MAXROWS=66
cols MAXCOLS
page MAXROWS
rows MAXROWS

const CUSTOMER_COPY=1
const FILE_COPY=2
const INTERNAL_COPY=3
pcopies 3

prepage {
	#get header info for better placement
	title$=trim(get(34,2,8))
	estreprint$=trim(get(72,2,7))
	# get comp info from page or constants?
	compname$=trim(get(20,3,40))
	if compname$="" then \
			compname$="COMP_NAME"; \
			addr1$="COMP_ADDR1"; \
			addr2$="COMP_ADDR2"; \
			addr3$="COMP_ADDR3"; \
			phone$="Phone: COMP_PHONES" \
		else \
			addr1$=trim(get(20,4,46)); \
			addr2$=trim(get(20,5,46)); \
			addr3$=trim(get(20,6,46)); \
			phone$=trim(get(20,7,46)); \
			if phone$="" then if addr3$="" or \
					addr3$(1,1)>="A" then \
					phone$="Phone: COMP_PHONES" \
				else \
					phone$="Phone: "+addr3$,addr3$="" \
				else 	phone$="Phone: "+phone$
	if addr3$="" then addr3$=phone$,phone$=""

	estname$=trim(get(7,8,40))
	estno$=trim(get(70,3,8))
	estpage$=trim(get(77,5,3))
	estdate$=trim(get(70,7,8))
	cust_code$=trim(get(58,10,20))
	shipto_code$=trim(get(15,10,15))
	jobname$=trim(get(8,8,40))
}

precopy {
	if copy=INTERNAL_COPY then cols$="100"
	if trim(get(83,3,8))<>"ESTIMATE" and \
		copy=INTERNAL_COPY then skip=1
}

# erase columns !
cerase 1,1,1,MAXROWS
cerase 80,1,81,MAXROWS
cerase 100,1,100,MAXROWS

# erase rows - or =
cerase 1,1,100,1
cerase 1,15,100,15
cerase 1,17,100,17
cerase 1,19,100,19
cerase 1,21,100,21
cerase 1,23,100,23
cerase 1,25,100,25
cerase 1,60,100,60
cerase 1,MAXROWS,100,MAXROWS

# erase cost section if not copy 3
if copy CUSTOMER_COPY,FILE_COPY
	cerase 81,1,100,MAXROWS
end if

# header
cerase 1,1,100,10
cbox LEFTCOL,1,MAXCOLS,MAXROWS,MBOXSIZE
cbox LEFTCOL,1,MAXCOLS,10,MBOXSIZE
if copy INTERNAL_COPY
	cbox 81,1,100,MAXROWS,MBOXSIZE
end if
LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
text 1,2,{title$},HBRFONT,16,cols=MAXRCOLS
text 1,3,{estreprint$},HRFONT,12,cols=MAXRCOLS
text 1,2,{compname$},HBCFONT,14,cols=MAXRCOLS
text 1,3.2,{addr1$},HCFONT,12,cols=MAXRCOLS
text 1,4.3,{addr2$},HCFONT,12,cols=MAXRCOLS
text 1,5.4,{addr3$},HCFONT,12,cols=MAXRCOLS
text 1,6.5,{phone$},HCFONT,12,cols=MAXRCOLS
text 1,7.5,"COMP_EMAIL",HCFONT,cols=MAXRCOLS
text 1,8.5,"COMP_WEBSITE",HCFONT,cols=MAXRCOLS
text 1,9.5,{"Job: "+jobname$},HCFONT,12,cols=MAXRCOLS
if copy CUSTOMER_COPY
	text 65,4.5,"Customer Copy",HBCFONT,12,cols=15,shade 0
end if
if copy FILE_COPY
	text 65,4.5,"File Copy",HBCFONT,12,cols=15,shade 0
end if
if copy INTERNAL_COPY
	text 65,4.5,"Internal Copy",HBCFONT,12,cols=15,shade 0
end if

# right header
cbox 64,3.75,MAXCOLS,5.25,1,100
cbox 64,5.5,MAXCOLS,10
cbox 64,5.5,72,10,1,ISHADE
cbox 64,5.5,MAXCOLS,7
cbox 64,8.5,MAXCOLS,8.5
text 65,6.25,"Number",IFONT
text 65,7.75,"Date",IFONT
text 65,9.25,"Page",IFONT
if copy CUSTOMER_COPY,FILE_COPY
	text 73,6.25,{estno$},DBFONT
	text 73,7.75,{estdate$},DBFONT
	text 73,9.25,{estpage$},DBFONT
end if
if copy INTERNAL_COPY
	text 73,6.25,{estno$},DSBFONT
	text 73,7.75,{estdate$},DSBFONT
	text 73,9.25,{estpage$},DSBFONT
	cbox 81,1,100,4
	cbox 81,1,90,4,1,ISHADE
	cbox 81,4,100,6
	cbox 81,4,90,6,1,ISHADE
	text 82,3,"Number",IFONT
	text 82,5,"Customer",IFONT
	text 92,3,{estno$},DSBFONT
	text 92,5,{cust_code$},DSBFONT
end if

# ship to section
cbox LEFTCOL,10,MAXCOLS,15,MBOXSIZE
cbox LEFTCOL,10,10,15,1,ISHADE
text 2,11,"Ship To:",IFONT
cmove 7,11,41,14,11,11
if copy CUSTOMER_COPY,FILE_COPY
	text 2,12,{shipto_code$},DSBFONT
	cfont 11,11,41,14,DBFONT			# ship to addr
end if
if copy INTERNAL_COPY
	text 2,12,{shipto_code$},DSBFONT,7
	cfont 11,11,40,14,DSBFONT			# ship to addr
end if

# bill to section
cbox 41,10,50,15,1,ISHADE
text 42,11,"Bill To:",IFONT
cmove 49,11,MAXRCOLS,14,51,11
if copy CUSTOMER_COPY,FILE_COPY
	text 42,12,{cust_code$},DSBFONT
	cfont 51,11,MAXCOLS,14,DBFONT			# bill to addr
end if
if copy INTERNAL_COPY
	text 42,12,{cust_code$},DSBFONT,7
	cfont 51,11,MAXCOLS,14,DSBFONT		# bill to addr
end if

# ribbon 1 section
cerase 17,16,17,18
cerase 26,16,26,18
cerase 36,16,36,18
cerase 52,16,52,18
cerase 55,16,55,18
cerase 63,16,63,18
cbox LEFTCOL,15,MAXCOLS,23,MBOXSIZE
cbox LEFTCOL,15,MAXCOLS,17,1,ISHADE
cbox 17,15,26,19
cbox 36,15,52,19
cbox 55,15,63,19
cfont 2,16,16,16,IFONT					# ref no
cfont 18,16,25,16,ICFONT				# expires
cfont 27,16,35,16,ICFONT				# estimator
cfont 37,16,51,16,IFONT					# terms
cfont 53,16,54,16,ICFONT				# whs
cfont 56,16,62,16,ICFONT				# frt
cfont 64,16,MAXRCOLS,16,IFONT				# ship via

if copy CUSTOMER_COPY,FILE_COPY
	cfont 2,18,16,18,DBFONT				# ref #
	cfont 18,18,25,18,DBCFONT			# expires
	cfont 27,18,35,18,DBCFONT			# estimator
	cfont 37,18,51,18,DBFONT			# terms
	cfont 53,18,54,18,DBCFONT			# whs
	cfont 56,18,62,18,DBCFONT			# frt
	cfont 64,18,MAXRCOLS,18,DBFONT		# ship via
end if
if copy INTERNAL_COPY
	cfont 2,18,16,18,DSBFONT			# ref #
	cfont 18,18,25,18,DSBCFONT			# expires
	cfont 27,18,35,18,DSBCFONT			# estimator
	cfont 37,18,51,18,DSBFONT			# terms
	cfont 53,18,54,18,DSBCFONT			# whs
	cfont 56,18,62,18,DSBCFONT			# frt
	cfont 64,18,MAXRCOLS,18,DSBFONT		# ship via
end if

# ribbon 2 section
cerase 33,20,33,22
cerase 42,20,42,22
cerase 51,20,51,22
cbox LEFTCOL,19,MAXCOLS,21,1,ISHADE
cbox LEFTCOL,21,MAXCOLS,23
cbox 33,19,42,23
cbox 51,19,MAXCOLS,23
cfont 2,20,32,20,IFONT					# billing
cfont 34,20,41,20,ICFONT				# start
cfont 43,20,50,20,ICFONT				# finish
cfont 52,20,MAXCOLS,20,IFONT				# units

if copy CUSTOMER_COPY,FILE_COPY
	cfont 2,22,32,22,DBFONT				# billing
	cfont 34,22,41,22,DBCFONT			# start
	cfont 43,22,50,22,DBCFONT			# finish
	cfont 52,22,MAXCOLS,22,DBFONT			# units
end if
if copy INTERNAL_COPY
	cfont 2,22,32,22,DSBFONT			# billing
	cfont 34,22,41,22,DSBCFONT			# start
	cfont 43,22,50,22,DSBCFONT			# finish
	cfont 52,22,MAXCOLS,22,DSBFONT		# units
end if

# detail
cerase 6,24,6,63
cerase 45,24,45,63
cerase 55,24,55,63
cerase 58,24,58,63
cerase 68,24,68,63
cerase 83,24,83,63
cerase 93,24,93,63
cbox LEFTCOL,23,MAXCOLS,64,MBOXSIZE
cbox LEFTCOL,23,MAXCOLS,25,1,DSHADE
cbox 6,23,6,64
cbox 45,23,45,64
cbox 55,23,55,64
cbox 58,23,58,64
cbox 68,23,68,64
cfont 2,24,5,24,ICFONT					# code
cfont 7,24,44,24,IFONT					# desc
cfont 46,24,54,24,IRFONT				# units
cfont 56,24,57,24,ICFONT				# uom
cfont 59,24,67,24,IRFONT				# price
cfont 69,24,MAXRCOLS,24,ICFONT			# extension

if copy CUSTOMER_COPY,FILE_COPY
	JC_EST_CFONT 2,26,5,63,DBCFONT		# code
	JC_EST_CFONT 7,26,44,63,DFONT			# desc
	JC_EST_CFONT 46,26,54,63,DBRFONT		# units
	JC_EST_CFONT 56,26,57,63,DBCFONT		# uom
	JC_EST_CFONT 59,26,67,63,DBRFONT		# price
	JC_EST_CFONT 69,26,MAXRCOLS,63,DBPFONT	# extension
end if
if copy INTERNAL_COPY
	JC_EST_CFONT 2,26,5,63,DSBCFONT		# code
	JC_EST_CFONT 7,26,44,63,DSFONT		# desc
	JC_EST_CFONT 46,26,54,63,DSBRFONT		# units
	JC_EST_CFONT 56,26,57,63,DSBCFONT		# uom
	JC_EST_CFONT 59,26,67,63,DSBRPFONT		# price
	JC_EST_CFONT 69,26,MAXRCOLS,63,DSBPFONT	# extension
	cbox 81,23,100,64,MBOXSIZE
	cbox 81,23,100,25,1,DSHADE
	cbox 93,23,93,64
	cfont 82,24,92,24,ICFONT			# cost
	cfont 94,24,99,24,IRFONT			# gm
	JC_EST_CFONT 82,26,92,63,DSBPFONT		# cost
	JC_EST_CFONT 94,26,99,63,DSBPFONT		# gm
end if

# footer
cerase LEFTCOL,64,100,64
cerase 9,64,9,MAXROWS
cerase 30,64,30,MAXROWS
cerase 47,64,47,MAXROWS
cerase 61,64,61,MAXROWS
cerase 93,64,93,MAXROWS
cbox LEFTCOL,64,MAXCOLS,MAXROWS,MBOXSIZE
cbox 11,64,MAXCOLS,MAXROWS
cbox 11,64,20,MAXROWS,1,HSHADE
cbox 30,64,38,MAXROWS,1,HSHADE
cbox 47,64,51,MAXROWS,1,HSHADE
cbox 61,64,68,MAXROWS,1,HSHADE
cfont 10,65,19,65,IBRFONT				# subtot
cfont 31,65,37,65,IBRFONT				# frt
cfont 48,65,50,65,IBRFONT				# tax
cfont 62,65,67,65,IBRFONT,10				# tot

if copy CUSTOMER_COPY,FILE_COPY
	cfont 21,65,29,65,DBFONT				# subtot
	cfont 39,65,46,65,DBFONT				# frt
	cfont 52,65,60,65,DBFONT				# tax
	cfont 69,65,MAXRCOLS,65,DBPFONT,10			# tot
end if
if copy INTERNAL_COPY
	cfont 21,65,29,65,DSBFONT				# subtot
	cfont 39,65,46,65,DSBFONT				# frt
	cfont 52,65,60,65,DSBFONT				# tax
	cfont 69,65,MAXRCOLS,65,DSBPFONT,9			# tot
	cbox 81,64,100,MAXROWS,MBOXSIZE
	cbox 93,64,93,MAXROWS
	cfont 82,65,92,65,IBCFONT,9			# tot cost
	cfont 94,65,99,65,IBFONT			# gm
	cfont 82,65,92,65,DSBPFONT,9			# tot cost
	cfont 94,63,99,65,DSBRFONT			# gm
end if

[J/C Invoice]
# Handles with and without cost tearoff
# Static Control 	12-66, 13-N, 14-Y/N
detect 0,2,"INVOICE"
detect 0,16,"JOB#"

# document options
const MAXCOLS=80
const MAXRCOLS=79
const LEFTCOL=1
const MAXROWS=66
cols MAXCOLS
page MAXROWS
rows MAXROWS

const CUSTOMER_COPY=1
const FILE_COPY=2
const INTERNAL_COPY=3
pcopies 3

prepage {
	#get header info for better placement
	title$=trim(get(40,2,7))
	invreprint$=trim(get(70,2,7))
	# get comp info from page or constants?
	compname$=trim(get(20,3,40))
	if compname$="" then \
			compname$="COMP_NAME"; \
			addr1$="COMP_ADDR1"; \
			addr2$="COMP_ADDR2"; \
			addr3$="COMP_ADDR3"; \
			phone$="Phone: COMP_PHONES" \
		else \
			addr1$=trim(get(20,4,46)); \
			addr2$=trim(get(20,5,46)); \
			addr3$=trim(get(20,6,46)); \
			phone$=trim(get(20,7,46)); \
			if phone$="" then if addr3$="" or \
					addr3$(1,1)>="A" then \
					phone$="Phone: COMP_PHONES" \
				else \
					phone$="Phone: "+addr3$,addr3$="" \
				else 	phone$="Phone: "+phone$
	if addr3$="" then addr3$=phone$,phone$=""

	invno$=trim(get(70,3,8))
	invpage$=trim(get(70,5,3))
	invdate$=trim(get(71,7,8))
	cust_code$=trim(get(16,10,25))
	shipto_code$=trim(get(57,10,15))
	jobno$=trim(get(91,5,8))
}

precopy {
	if copy=INTERNAL_COPY then cols$="100"
	if trim(get(83,3,7))<>"INVOICE" and \
			copy=INTERNAL_COPY then skip=1
}

# erase columns !
cerase 1,1,1,MAXROWS
cerase 80,1,81,MAXROWS
cerase 100,1,100,MAXROWS

# erase rows - or =
cerase 1,1,100,1
cerase 1,15,100,15
cerase 1,17,100,17
cerase 1,19,100,19
cerase 1,21,100,21
cerase 1,23,100,23
cerase 1,25,100,25
cerase 1,60,100,60
cerase 1,MAXROWS,100,MAXROWS

# erase cost section if not copy 3
if copy CUSTOMER_COPY,FILE_COPY
	cerase 81,1,100,MAXROWS
end if

# header
cerase 1,1,100,10
cbox LEFTCOL,1,MAXCOLS,MAXROWS,MBOXSIZE
cbox LEFTCOL,1,MAXCOLS,10,MBOXSIZE
if copy INTERNAL_COPY
	cbox 81,1,100,MAXROWS,MBOXSIZE
end if
LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
text 1,2,{title$},HBRFONT,16,cols=MAXRCOLS
text 1,3,{invreprint$},HRFONT,12,cols=MAXRCOLS
text 1,2,{compname$},HBCFONT,14,cols=MAXRCOLS
text 1,3.2,{addr1$},HCFONT,12,cols=MAXRCOLS
text 1,4.3,{addr2$},HCFONT,12,cols=MAXRCOLS
text 1,5.4,{addr3$},HCFONT,12,cols=MAXRCOLS
text 1,6.5,{phone$},HCFONT,12,cols=MAXRCOLS
text 1,7.5,"COMP_EMAIL",HCFONT,cols=MAXRCOLS
text 1,8.5,"COMP_WEBSITE",HCFONT,cols=MAXRCOLS
if copy CUSTOMER_COPY
	text 65,4.5,"Customer Copy",HBCFONT,12,cols=15,shade 0
end if
if copy FILE_COPY
	text 65,4.5,"File Copy",HBCFONT,12,cols=15,shade 0
end if
if copy INTERNAL_COPY
	text 65,4.5,"Internal Copy",HBCFONT,12,cols=15,shade 0
end if

# right header
cbox 64,3.75,MAXCOLS,5.25,1,100
cbox 64,5.5,MAXCOLS,10
cbox 64,5.5,72,10,1,ISHADE
cbox 64,7,MAXCOLS,8.5
text 65,6.25,"Number",IFONT
text 65,7.75,"Date",IFONT
text 65,9.25,"Page",IFONT
if copy CUSTOMER_COPY,FILE_COPY
	text 73,6.25,{invno$},DBFONT
	text 73,7.75,{invdate$},DBFONT
	text 73,9.25,{invpage$},DBFONT
end if
if copy INTERNAL_COPY
	text 73,6.25,{invno$},DSBFONT
	text 73,7.75,{invdate$},DSBFONT
	text 73,9.25,{invpage$},DSBFONT
	cbox 81,1,100,4
	cbox 81,1,90,4,1,ISHADE
	cbox 81,4,100,6
	cbox 81,4,90,6,1,ISHADE
	cbox 81,6,100,8
	cbox 81,6,90,8,1,ISHADE
	text 82,3,"Invoice #",IFONT
	text 82,5,"Job #",IFONT
	text 82,7,"Customer",IFONT
	text 92,3,{invno$},DSBFONT
	text 92,5,{jobno$},DSBFONT
	text 92,7,{cust_code$},DSBFONT
end if

# bill to section
cbox LEFTCOL,10,MAXCOLS,15,MBOXSIZE
cbox LEFTCOL,10,10,15,1,ISHADE
text 2,11,"Bill To:",IFONT
cmove 7,11,41,14,11,11
if copy CUSTOMER_COPY,FILE_COPY
	text 2,12,{cust_code$},DSBFONT
	cfont 11,11,40,14,DBFONT			# bill to addr
end if
if copy INTERNAL_COPY
	text 2,12,{cust_code$},DSBFONT,7
	cfont 11,11,40,14,DSBFONT			# bill to addr
end if

# ship to section
cbox 41,10,50,15,1,ISHADE
text 42,11,"Ship To:",IFONT
cmove 49,11,MAXRCOLS,14,51,11
if copy CUSTOMER_COPY,FILE_COPY
	text 42,12,{shipto_code$},DSBFONT
	cfont 51,11,MAXCOLS,14,DBFONT			# ship to addr
end if
if copy INTERNAL_COPY
	text 42,12,{shipto_code$},DSBFONT,7
	cfont 51,11,MAXCOLS,14,DSBFONT		# ship to addr
end if

# ribbon 1 section
cerase 10,15,10,19
cerase 41,15,41,19
cerase 52,15,52,19
cbox LEFTCOL,15,MAXCOLS,23,MBOXSIZE
cbox LEFTCOL,15,MAXCOLS,17,1,ISHADE
cbox 10,15,41,19
cbox 52,15,MAXCOLS,19	
cfont 2,16,9,16,ICFONT					# job #
cfont 11,16,40,16,IFONT					# name 
cfont 42,16,51,16,IFONT					# contract #
cfont 53,16,MAXRCOLS,16,IFONT				# manager

if copy CUSTOMER_COPY,FILE_COPY
	cfont 2,18,9,18,DBCFONT				# job #
	cfont 11,18,40,18,DBFONT			# name
	cfont 42,18,51,18,DBFONT			# contract #
	cfont 53,18,MAXRCOLS,18,DBFONT		# manager
end if
if copy INTERNAL_COPY
	cfont 2,18,9,18,DSBCFONT			# job #
	cfont 11,18,40,18,DSBFONT			# name
	cfont 42,18,51,18,DSBFONT			# contract #
	cfont 53,18,MAXRCOLS,18,DSBFONT		# manager
end if

# ribbon 2 section
cerase 17,20,17,22
cerase 23,20,23,22
cerase 39,20,39,22
cerase 48,20,48,22
cerase 51,20,51,22
cbox LEFTCOL,19,MAXCOLS,21,1,ISHADE
cbox LEFTCOL,21,MAXCOLS,23
cbox 17,19,17,23
cbox 23,19,23,23
cbox 39,19,39,23
cbox 48,19,48,23
cbox 51,19,51,23
cfont 2,20,16,20,IFONT					# ref #
cfont 18,20,22,20,ICFONT				# salesperson
cfont 24,20,38,20,IFONT					# terms
cfont 40,20,47,20,IFONT					# tax code
cfont 49,20,50,20,ICFONT				# whs
cfont 52,20,MAXRCOLS,20,IFONT				# billing

if copy CUSTOMER_COPY,FILE_COPY
	cfont 2,22,16,22,DBFONT				# ref #
	cfont 18,22,22,22,DBCFONT			# salesperson
	cfont 24,22,38,22,DBFONT			# terms
	cfont 40,22,47,22,DBFONT			# tax code
	cfont 49,22,50,22,DBCFONT			# whs
	cfont 52,22,MAXRCOLS,22,DBFONT		# billing
end if
if copy INTERNAL_COPY
	cfont 2,22,16,22,DSBFONT			# ref #
	cfont 18,22,22,22,DSBCFONT			# salesperson
	cfont 24,22,38,22,DSBFONT			# terms
	cfont 40,22,47,22,DSBFONT			# tax code
	cfont 49,22,50,22,DSBCFONT			# whs
	cfont 52,22,MAXRCOLS,22,DSBFONT		# billing
end if

# detail
cerase 68,24,68,60
cerase 83,24,83,60
cerase 93,24,93,60
cbox LEFTCOL,23,MAXCOLS,60,MBOXSIZE
cbox LEFTCOL,23,MAXCOLS,25,1,DSHADE
cbox 68,23,MAXCOLS,60
cfont 2,24,67,24,IFONT					# desc
cfont 69,24,MAXRCOLS,24,ICFONT			# amt

if copy CUSTOMER_COPY,FILE_COPY
	JC_INV_CFONT 2,26,67,60,DFONT			# desc
	JC_INV_CFONT 69,26,MAXRCOLS,60,DBPFONT	# amt
end if
if copy INTERNAL_COPY
	JC_INV_CFONT 2,26,67,60,DSFONT		# desc
	JC_INV_CFONT 69,26,MAXRCOLS,60,DSBPFONT	# amt
	cbox 81,23,100,60,MBOXSIZE
	cbox 81,23,100,25,1,DSHADE
	cbox 93,23,93,60
	cfont 82,24,92,24,IRFONT			# cost
	cfont 94,24,99,24,IRFONT			# gm
	JC_INV_CFONT 82,26,92,63,DSBRFONT		# cost
	JC_INV_CFONT 94,26,99,63,DSBRFONT		# gm
end if

# footer
cerase 36,62,100,62
cerase 36,64,100,64
cerase 36,61,36,64
cerase 48,61,48,63
cerase 57,61,57,63
cerase 67,61,67,63
cerase 93,61,93,63
cbox LEFTCOL,60,MAXCOLS,MAXROWS,MBOXSIZE
cbox 36,60,MAXCOLS,62,1,HSHADE
cbox 36,62,MAXCOLS,64
cbox 48,60,57,64
cbox 67,60,67,64
cfont 37,61,47,61,IBRFONT				# amt
cfont 50,61,56,61,IBRFONT				# frt
cfont 58,61,66,61,IBRFONT				# tax
cfont 68,61,MAXRCOLS,61,IBRFONT,10			# tot due

if copy CUSTOMER_COPY,FILE_COPY
	cfont 37,63,47,63,DBRFONT			# amt
	cfont 50,63,56,63,DBRFONT			# frt
	cfont 58,63,66,63,DBRFONT			# tax
	cfont 68,63,MAXRCOLS,63,DBRFONT,10		# tot due
end if
if copy INTERNAL_COPY
	cfont 37,63,47,63,DSBRFONT			# amt
	cfont 50,63,56,63,DSBRFONT			# frt
	cfont 58,63,66,63,DSBRFONT			# tax
	cfont 68,63,MAXRCOLS,63,DSBRFONT,9		# tot due
	cbox 81,60,100,MAXROWS,MBOXSIZE
	cbox 81,60,100,62,1,HSHADE
	cbox 81,62,100,64
	cbox 93,60,93,64
	cfont 82,61,92,61,IBCFONT,9			# tot cost
	cfont 94,61,99,61,IBRFONT			# gm
	cfont 82,63,92,63,DSBPFONT,9			# tot cost
	cfont 94,63,99,63,DSBRFONT			# gm
end if
if copy CUSTOMER_COPY,FILE_COPY
	cfont 2,61,35,64,DFONT
	cfont 2,65,MAXCOLS,65,DFONT
end if
if copy INTERNAL_COPY
	cfont 2,61,35,64,DSFONT
	cfont 2,65,MAXCOLS,65,DSFONT
end if

[M/C Production Ticket]
detect 0,3,"PRODUCTION TICKET"

# document options
const MAXCOLS=80
const MAXRCOLS=79
const LEFTCOL=1
const MAXROWS=66
cols MAXCOLS
page MAXROWS
rows MAXROWS

const WHSE_COPY=1
const FILE_COPY=2
pcopies 2

prepage {
	#get header info for better placement
	compname$=trim(get(20,2,40))
	ticketno$=trim(get(70,2,6))
	title$=trim(get(20,3,40))
	ticketdate$=trim(get(70,3,8))
	whse$=trim(get(70,4,2))

	desc_pos=pos("DESCRIPTION"=text$[10])
	# find memo lines and mark them for enhancing later
	for i=12 to 61
		# blank line?
		if trim(text$[i])="" then continue
		# if item # exists; must be item line
		if trim(text$[i](6,desc_pos-2-6))<>"" then continue
		# must be memo line or 2nd desc line
		text$[i](desc_pos-3,2)="mL"
	next i
}

# erase columns !
cerase 1,1,1,MAXROWS
cerase 79,1,79,MAXROWS

# erase rows - or =
cerase 1,1,MAXCOLS,1
cerase 1,11,MAXCOLS,11
cerase 1,62,MAXCOLS,62
cerase 1,65,MAXCOLS,65
cerase 1,MAXROWS,MAXCOLS,MAXROWS

# default detail line
cfont 2,12,4,61,DCFONT					# line #
const XMASK="DESCRIPTION@1,10,37,10"
cfont "XMASK",-2,2,6,61,DBFONT,ITEM_JUSTIFY 	# item
cfont "XMASK",0,2,42,61,DSFONT			# desc
cfont 44,12,52,61,DBRFONT				# units
cfont 54,12,55,61,DBCFONT				# um
cfont 57,12,MAXRCOLS,61,DSFONT			# memo

# header
cerase 1,1,MAXCOLS,5
cbox LEFTCOL,1,MAXCOLS,MAXROWS,MBOXSIZE
cbox LEFTCOL,1,MAXCOLS,9,MBOXSIZE
text 1,2,{title$},HBCFONT,16,cols=MAXRCOLS
text 1,4,{compname$},HBCFONT,14,cols=MAXRCOLS
cfont 2,6,MAXCOLS,6,IFONT
cfont 2,8,MAXCOLS,8,IFONT
cbox 65,1.25,MAXCOLS,3,1,100
if copy WHSE_COPY
	text 65,2.25,"Warehouse Copy",HBCFONT,12,cols=16,shade 0
end if
if copy FILE_COPY
	text 65,2.25,"File Copy",HBCFONT,12,cols=16,shade 0
end if

# right header
cbox 65,3.5,MAXCOLS,8
cbox 65,3.5,73,8,1,ISHADE
cbox 65,5,MAXCOLS,6.5
text 66,4.25,"Number",IFONT
text 66,5.75,"Date",IFONT
text 66,7.25,"Whse",IFONT
text 74,4.25,{ticketno$},DSBFONT
text 74,5.75,{ticketdate$},DSBFONT
text 74,7.25,{whse$},DSBFONT

# detail heading
cbox LEFTCOL,9,MAXCOLS,61,MBOXSIZE
cbox LEFTCOL,9,MAXCOLS,11,1,DSHADE
cbox 5,9,5,61
box "DESCRIPTION@6,10,37,10",-1,-1,1,52
cbox 43,9,44,61
cbox 53,9,53,61
cbox 56,9,56,61
cfont "XMASK",-2,0,6,10,IFONT,ITEM_JUSTIFY 	# item
cfont "XMASK",0,0,42,10,IFONT				# desc
cfont 45,10,52,10,IRFONT				# units
cfont 54,10,55,10,ICFONT				# um
cfont 57,10,MAXRCOLS,10,IFONT				# memo

# detail exceptions
font "mL@1,12,27,61",3,0,60,1,DSFONT		# memo lines
erase "mL@1,12,27,61",0,0,2,1				# spec chars

# footer
cbox LEFTCOL,61,MAXCOLS,MAXROWS,MBOXSIZE
cfont 1,64,MAXRCOLS,64,DRFONT

[S/O Bills of Lading]
# BOL Control	1-N, 2-Y/N, 3-Y/N
detect 0,1,"STRAIGHT BILL OF LADING"

# document options
const MAXCOLS=81
const MAXRCOLS=80
const LEFTCOL=1
const MAXROWS=57
cols MAXCOLS
page MAXROWS
rows MAXROWS

const CUSTOMER_COPY=1
const FILE_COPY=2
pcopies 2

prepage {
	#get header info for better placement
	title$=trim(get(56,1,24))
	orig$=trim(get(56,2,24))
	reprint$=trim(get(71,4,7))
	# get comp info from page or constants?
	compname$=trim(get(10,3,40))
	if compname$="" then \
			compname$="COMP_NAME"; \
			addr1$="COMP_ADDR1"; \
			addr2$="COMP_ADDR2"; \
			addr3$="COMP_ADDR3"; \
			phone$="Phone: COMP_PHONES" \
		else \
			addr1$=trim(get(10,4,46)); \
			addr2$=trim(get(10,5,46)); \
			addr3$=trim(get(10,6,46)); \
			phone$=trim(get(10,7,46)); \
			if phone$="" then if addr3$="" or \
					addr3$(1,1)>="A" then \
					phone$="Phone: COMP_PHONES" \
				else \
					phone$="Phone: "+addr3$,addr3$="" \
				else 	phone$="Phone: "+phone$
	if addr3$="" then addr3$=phone$,phone$=""

	docno$=trim(get(74,6,6))
	page$=trim(get(63,10,3))
	date$=trim(get(72,8,8))
	shipto_code$=trim(get(10,12,15))
}

# erase rows - or =
cerase 1,18,MAXCOLS,18
cerase 1,20,MAXCOLS,20
cerase 1,22,MAXCOLS,22
cerase 1,36,MAXCOLS,36
cerase 1,38,MAXCOLS,38
cerase 1,40,MAXCOLS,40
cerase 1,45,MAXCOLS,45
cerase 1,53,MAXCOLS,53
cerase 1,57,MAXCOLS,57

# header
cerase 1,1,MAXCOLS,12
LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
text 1,1.1,{title$},HBRFONT,16,cols=MAXRCOLS
text 1,2.1,{orig$},HBRFONT,12,cols=MAXRCOLS
text 1,3.2,{reprint$},HRFONT,12,cols=MAXRCOLS
text 1,2,{compname$},HBCFONT,14,cols=MAXRCOLS
text 1,3.2,{addr1$},HCFONT,12,cols=MAXRCOLS
text 1,4.3,{addr2$},HCFONT,12,cols=MAXRCOLS
text 1,5.4,{addr3$},HCFONT,12,cols=MAXRCOLS
text 1,6.5,{phone$},HCFONT,12,cols=MAXRCOLS
text 1,7.5,"COMP_EMAIL",HCFONT,cols=MAXRCOLS
text 1,8.5,"COMP_WEBSITE",HCFONT,cols=MAXRCOLS
if copy CUSTOMER_COPY
	text 65,4.5,"Customer Copy",HBCFONT,12,cols=15,shade 0
end if
if copy FILE_COPY
	text 65,4.5,"File Copy",HBCFONT,12,cols=15,shade 0
end if

# right header
cbox 64,3.75,MAXCOLS,5.25,1,100
cbox 64,5.5,MAXCOLS,10
cbox 64,5.5,72,10,1,ISHADE
cbox 64,5.5,MAXCOLS,7
cbox 64,8.5,MAXCOLS,8.5
text 65,6.25,"Number",IFONT
text 65,7.75,"Date",IFONT
text 65,9.25,"Page",IFONT
text 73,6.25,{docno$},DBFONT
text 73,7.75,{date$},DBFONT 
text 73,9.25,{page$},DBFONT
text 75,9.25,"of   ___",IFONT

# ship to section
cerase 1,13,1,17
cbox LEFTCOL,11,MAXCOLS,18,MBOXSIZE
cbox LEFTCOL,11,11,18,1,ISHADE
text 2,12,"Ship To:",IFONT
text 2,13,{shipto_code$},DBFONT
cmove 10,13,50,17,12,13
cfont 12,13,41,17,DBFONT				# ship to addr

# ribbon 1 section
cerase 8,18,8,20
cerase 31,18,31,20
cerase 34,18,34,20
cerase 38,18,38,20
cerase 44,18,44,20
cbox LEFTCOL,18,MAXCOLS,20,MBOXSIZE
cbox LEFTCOL,18,8,20,1,ISHADE
cbox 31,18,34,20,1,ISHADE
cbox 38,18,44,20,1,ISHADE
cfont 1,19,7,19,IRFONT				# carrier
cfont 32,19,33,19,IRFONT			# whs
cfont 39,19,43,19,IRFONT			# notes

cfont 9,19,30,19,DBFONT				# carrier
cfont 35,19,37,19,DBFONT			# whs
cfont 45,19,MAXCOLS,19,DFONT			# notes

# detail
cerase 7,20,7,36
cerase 11,20,11,36
cerase 66,20,66,36
cerase 75,20,75,36
cbox LEFTCOL,20,MAXCOLS,36,MBOXSIZE
cbox LEFTCOL,20,MAXCOLS,22,1,DSHADE
cbox 7,20,11,36
cbox 66,20,75,36
cfont 1,21,6,21,IRFONT					# units
cfont 8,21,10,21,ICFONT					# hm ??
cfont	12,21,65,21,IFONT					# desc
cfont 67,21,74,21,IRFONT				# wt
cfont 76,21,MAXRCOLS,21,ICFONT			# class

SO_BOL_CFONT 1,23,6,36,DBRFONT			# units
SO_BOL_CFONT 8,23,10,36,DBCFONT			# hm ??
SO_BOL_CFONT 12,23,65,36,DFONT			# desc
SO_BOL_CFONT 67,23,74,36,DBRFONT			# wt
SO_BOL_CFONT 76,23,MAXRCOLS,36,DBCFONT		# class

# continued
cbox LEFTCOL,36,MAXCOLS,38,MBOXSIZE,ISHADE
cfont LEFTCOL,37,MAXRCOLS,37,IBRFONT

# emergency contact
cbox LEFTCOL,38,MAXCOLS,40,MBOXSIZE
cbox LEFTCOL,38,28,40,1,DSHADE
cfont LEFTCOL,39,27,39,IRFONT				# emer contact
cfont 29,39,MAXCOLS,39,DBFONT				# emer contact

# rules
cbox LEFTCOL,40,MAXCOLS,53,MBOXSIZE
cbox LEFTCOL,45,MAXCOLS,45
cfont LEFTCOL,41,MAXRCOLS,44,DBCFONT
cfont LEFTCOL,46,MAXRCOLS,52,DBCFONT

# shipper
cerase 71,55,MAXCOLS,55
cbox LEFTCOL,53,MAXCOLS,57,MBOXSIZE
cbox LEFTCOL,53,8,57,1,ISHADE
cbox 45,53,64,57,1,ISHADE
cfont 1,54,7,54,IRFONT				# shipper
cfont 1,55,7,55,IRFONT				# signed
cfont 9,54,44,54,DBFONT
cfont 46,54,63,54,IRFONT			# rcv company
cfont 46,55,63,55,IRFONT			# signed
text 46,56,"DATE",IRFONT,cols=17		# dt

text 10,56,"___________________________",DFONT	# signed shipper
text 66,55,"__________________",DFONT		# signed rcv
text 66,56,"__________________",DFONT		# dt

[S/R Work Ticket]
detect 0,2,"WORK TICKET PRINT"

# document options
const MAXCOLS=85
const MAXRCOLS=84
const LEFTCOL=1
const MAXROWS=66
cols MAXCOLS
page MAXROWS
rows MAXROWS

const CUSTOMER_COPY=1
const FILE_COPY=2
const SERVICE_COPY=3
pcopies 3

prepage {
	#get header info for better placement
	title$=trim(get(35,2,11))
	# get comp info from page or constants?
	compname$=trim(get(20,3,40))
	if compname$="" then \
			compname$="COMP_NAME"; \
			addr1$="COMP_ADDR1"; \
			addr2$="COMP_ADDR2"; \
			addr3$="COMP_ADDR3"; \
			phone$="Phone: COMP_PHONES" \
		else \
			addr1$=trim(get(20,4,46)); \
			addr2$=trim(get(20,5,46)); \
			addr3$=trim(get(20,6,46)); \
			phone$=trim(get(20,7,46)); \
			if phone$="" then if addr3$="" or \
					addr3$(1,1)>="A" then \
					phone$="Phone: COMP_PHONES" \
				else \
					phone$="Phone: "+addr3$,addr3$="" \
				else 	phone$="Phone: "+phone$
	if addr3$="" then addr3$=phone$,phone$=""

	invno$=trim(get(78,3,7))
	invpage$=trim(get(82,5,3))
	invdate$=trim(get(76,7,8))
	cust_code$=trim(get(17,10,23))
	loc_code$=trim(get(64,10,15))
}


# erase columns !
cerase 1,1,1,MAXROWS
cerase MAXCOLS,1,MAXCOLS,MAXROWS

# erase rows - or =
cerase 1,1,MAXCOLS,1
cerase 1,15,MAXCOLS,15
cerase 1,17,MAXCOLS,17
cerase 1,19,MAXCOLS,19
cerase 1,62,MAXCOLS,62
cerase 1,65,MAXCOLS,65
cerase 1,MAXROWS,MAXCOLS,MAXROWS

# header
cerase 1,1,MAXCOLS,10,5
cbox LEFTCOL,1,MAXCOLS,MAXROWS,MBOXSIZE
cbox LEFTCOL,1,MAXCOLS,10,5
LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
text 1,2,{title$},HBRFONT,16,cols=MAXRCOLS
text 1,2,{compname$},HBCFONT,14,cols=MAXRCOLS
text 1,3.2,{addr1$},HCFONT,12,cols=MAXRCOLS
text 1,4.3,{addr2$},HCFONT,12,cols=MAXRCOLS
text 1,5.4,{addr3$},HCFONT,12,cols=MAXRCOLS
text 1,6.5,{phone$},HCFONT,12,cols=MAXRCOLS
text 1,7.5,"COMP_EMAIL",HCFONT,cols=MAXRCOLS
text 1,8.5,"COMP_WEBSITE",HCFONT,cols=MAXRCOLS
cbox 64,3.75,MAXCOLS,5.25,1,100
if copy CUSTOMER_COPY
	text 65,4.5,"Customer Copy",HBCFONT,12,cols=20,shade 0
end if
if copy FILE_COPY
	text 65,4.5,"File Copy",HBCFONT,12,cols=20,shade 0
end if
if copy SERVICE_COPY
	text 65,4.5,"Service Copy",HBCFONT,12,cols=20,shade 0
end if

# right header
cbox 64,5.5,MAXCOLS,10
cbox 64,5.5,72,10,1,ISHADE
cbox 64,7,MAXCOLS,7
cbox 64,8.5,MAXCOLS,8.5
text 65,6.25,"Number",IFONT
text 65,7.75,"Date",IFONT
text 65,9.25,"Page",IFONT
text 73,6.25,{invno$},DBFONT
text 73,7.75,{invdate$},DBFONT
text 73,9.25,{invpage$},DBFONT

# bill to section
cbox LEFTCOL,10,MAXCOLS,15,MBOXSIZE
cbox LEFTCOL,10,10,15,1,ISHADE
text 2,11,"Bill To:",IFONT
text 2,12,{cust_code$},DSBFONT
cmove 7,11,41,14,11,11
cfont 11,11,40,14,DBFONT			# ship to addr

# location section
cbox 41,10,50,15,1,ISHADE
text 42,11,"Location:",IFONT
text 42,12,{loc_code$},DSBFONT
cmove 49,11,MAXRCOLS,14,51,11
cfont 51,11,MAXCOLS,14,DBFONT			# bill to addr

# ribbon 1 section
cerase 17,15,17,19
cerase 26,15,26,19
cerase 36,15,36,19
cerase 41,15,41,19
cerase 57,15,57,19
cerase 61,15,61,19
cerase 69,15,69,19
cbox LEFTCOL,15,MAXCOLS,19,MBOXSIZE
cbox LEFTCOL,15,MAXCOLS,17,1,ISHADE
cbox 17,15,26,19
cbox 36,15,41,19
cbox 57,15,61,19
cbox 69,15,69,19
cfont 2,16,16,16,IFONT				# ref #
cfont 18,16,25,16,ICFONT			# order date
cfont 27,16,35,16,ICFONT			# requested
cfont 37,16,40,16,ICFONT			# slsp
cfont 42,16,56,16,IFONT				# terms
cfont 58,16,60,16,ICFONT			# whs
cfont	62,16,68,16,ICFONT			# freight
cfont 70,16,MAXCOLS,16,IFONT			# ship via

cfont 2,18,16,18,DBFONT				# ref #
cfont 18,18,25,18,DBCFONT			# order date
cfont 27,18,35,18,DBCFONT			# requested
cfont 37,18,40,18,DBCFONT			# slsp
cfont 42,18,56,18,DBFONT			# terms
cfont 58,18,60,18,DBCFONT			# whs
cfont 62,18,68,18,DBCFONT			# freight
cfont 70,18,MAXCOLS,18,DBFONT			# ship via

# detail
cbox LEFTCOL,19,MAXCOLS,62,MBOXSIZE

# footer
cbox LEFTCOL,62,MAXCOLS,MAXROWS,MBOXSIZE
cfont 2,63,MAXCOLS,65,DFONT

[A/R Invoice]
# handles both cost and no cost styles of A/R invoices
# Invoice Control	2-Y, 3-Y, 4-%, 9-N, 10-Y/N, 11-66
detect 0,2,"INVOICE"
detect 0,16,"INVOICED"

# document options
const MAXCOLS=80
const MAXRCOLS=79
const LEFTCOL=1
const MAXROWS=66
cols MAXCOLS
page MAXROWS
rows MAXROWS

const CUSTOMER_COPY=1
const FILE_COPY=2
const INTERNAL_COPY=3
pcopies 3

prepage {
	#get header info for better placement
	title$=trim(get(40,2,10))
	invreprint$=trim(get(71,2,7))
	# get comp info from page or constants?
	compname$=trim(get(20,3,40))
	if compname$="" then \
			compname$="COMP_NAME"; \
			addr1$="COMP_ADDR1"; \
			addr2$="COMP_ADDR2"; \
			addr3$="COMP_ADDR3"; \
			phone$="Phone: COMP_PHONES" \
		else \
			addr1$=trim(get(20,4,46)); \
			addr2$=trim(get(20,5,46)); \
			addr3$=trim(get(20,6,46)); \
			phone$=trim(get(20,7,46)); \
			if phone$="" then if addr3$="" or \
					addr3$(1,1)>="A" then \
					phone$="Phone: COMP_PHONES" \
				else \
					phone$="Phone: "+addr3$,addr3$="" \
				else 	phone$="Phone: "+phone$
	if addr3$="" then addr3$=phone$,phone$="" 

	invno$=trim(get(72,3,6))
	invpage$=trim(get(77,5,3))
	invdate$=trim(get(71,7,8))
	cust_code$=trim(get(20,10,20))
	shipto_code$=trim(get(57,10,15))
}

precopy {
	if copy=INTERNAL_COPY then cols$="100"
	if trim(get(84,3,3))<>"NO." and copy=INTERNAL_COPY then \
		skip=1
}

# erase columns !
cerase 1,1,1,MAXROWS
cerase 80,1,81,MAXROWS
cerase 100,1,100,MAXROWS

# erase rows - or =
cerase 1,1,100,1
cerase 1,15,100,15
cerase 1,17,100,17
cerase 1,19,100,19
cerase 1,21,100,21
cerase 1,60,100,60
cerase 1,MAXROWS,100,MAXROWS

# erase cost section if not copy 3
if copy CUSTOMER_COPY,FILE_COPY
	cerase 81,1,100,MAXROWS
end if

# header
cerase 1,1,100,10
cbox LEFTCOL,1,MAXCOLS,MAXROWS,MBOXSIZE
cbox LEFTCOL,1,MAXCOLS,10,MBOXSIZE
LOGO_IMAGE 1,1,10,5,"COMP_LOGO"
if copy INTERNAL_COPY
	cbox 81,1,100,MAXROWS,MBOXSIZE
end if
text 1,2,{title$},HBRFONT,16,cols=MAXRCOLS
text 1,3,{invreprint$},HRFONT,12,cols=MAXRCOLS
text 1,2,{compname$},HBCFONT,14,cols=MAXRCOLS
text 1,3.2,{addr1$},HCFONT,12,cols=MAXRCOLS
text 1,4.3,{addr2$},HCFONT,12,cols=MAXRCOLS
text 1,5.4,{addr3$},HCFONT,12,cols=MAXRCOLS
text 1,6.5,{phone$},HCFONT,12,cols=MAXRCOLS
text 1,7.5,"COMP_EMAIL",HCFONT,cols=MAXRCOLS
text 1,8.5,"COMP_WEBSITE",HCFONT,cols=MAXRCOLS
cbox 64,3.75,MAXCOLS,5,1,100
if copy CUSTOMER_COPY
	text 65,4.5,"Customer Copy",HBCFONT,12,cols=15,shade 0
end if
if copy FILE_COPY
	text 65,4.5,"File Copy",HBCFONT,12,cols=15,shade 0
end if
if copy INTERNAL_COPY
	text 65,4.5,"Internal Copy",HBCFONT,12,cols=15,shade 0
end if

# right header
cbox 64,5.5,MAXCOLS,10
cbox 64,5.5,72,10,1,ISHADE
cbox 64,7,MAXCOLS,8.5
text 65,6.25,"Number",IFONT
text 65,7.75,"Date",IFONT
text 65,9.25,"Page",IFONT
if copy CUSTOMER_COPY,FILE_COPY
	text 73,6.25,{invno$},DBFONT
	text 73,7.75,{invdate$},DBFONT
	text 73,9.25,{invpage$},DBFONT
end if
if copy INTERNAL_COPY
	text 73,6.25,{invno$},DSBFONT
	text 73,7.75,{invdate$},DSBFONT
	text 73,9.25,{invpage$},DSBFONT
	cbox 81,1,100,4
	cbox 81,1,90,4,1,ISHADE
	text 83,3,"Number",IFONT
	text 93.5,3,{invno$},DSBFONT
end if

# bill to section
cbox LEFTCOL,10,MAXCOLS,15,MBOXSIZE
cbox LEFTCOL,10,10,15,1,ISHADE
text 2,11,"Bill to:",IFONT
cmove 12,11,41,14,11,11
if copy CUSTOMER_COPY,FILE_COPY
	text 2,12,{cust_code$},DSBFONT
	cfont 11,11,40,14,DBFONT			# bill to addr
end if
if copy INTERNAL_COPY
	text 2,12,{cust_code$},DSBFONT,7
	cfont 11,11,40,14,DSBFONT			# bill to addr
end if

# ship to section
cbox 41,10,50,15,1,ISHADE
text 42,11,"Ship to:",IFONT
cmove 49,11,MAXRCOLS,14,51,11
if copy CUSTOMER_COPY,FILE_COPY
	text 42,12,{shipto_code$},DSBFONT
	cfont 51,11,MAXCOLS,14,DBFONT			# ship to addr
end if
if copy INTERNAL_COPY
	text 42,12,{shipto_code$},DSBFONT,7
	cfont 51,11,MAXCOLS,14,DSBFONT		# ship to addr
end if

# ribbon section
cerase 17,16,17,18
cerase 26,16,26,18
cerase 32,16,32,18
cerase 48,16,48,18
cerase 57,16,57,18
cerase 62,16,62,18
cbox LEFTCOL,15,MAXCOLS,19,MBOXSIZE
cbox LEFTCOL,15,MAXCOLS,17,1,ISHADE
cbox 17,15,26,19
cbox 32,15,48,19
cbox 57,15,62,19
cfont 2,16,16,16,IFONT					# ref #
cfont 18,16,25,16,ICFONT				# inv dt
cfont 27,16,31,16,ICFONT				# slsp
cfont 33,16,47,16,IFONT					# terms
cfont 49,16,56,16,IFONT					# tax code
cfont 58,16,61,16,ICFONT				# branch

if copy CUSTOMER_COPY,FILE_COPY
	cfont 2,18,16,18,DBFONT					# ref #
	cfont 18,18,25,18,DBCFONT				# inv dt
	cfont 27,18,31,18,DBCFONT				# slsp
	cfont 33,18,47,18,DBFONT				# terms
	cfont 49,18,56,18,DBFONT				# tax code
	cfont 58,18,61,18,DBCFONT				# branch
end if
if copy INTERNAL_COPY
	cfont 2,18,16,18,DSBFONT				# ref #
	cfont 18,18,25,18,DSBCFONT				# inv dt
	cfont 27,18,31,18,DSBCFONT				# slsp
	cfont 33,18,47,18,DSBFONT				# terms
	cfont 49,18,56,18,DSBFONT				# tax code
	cfont 58,18,61,18,DSBCFONT				# branch
end if

# detail
const XMASK=DESCRIPTION@2,20,40,20
erase "XMASK",-1,0,1,40
cerase 68,20,68,60
cerase 93,20,93,60
cbox LEFTCOL,19,MAXCOLS,60,MBOXSIZE
cbox LEFTCOL,19,MAXCOLS,21,1,DSHADE
box "XMASK",-1,-1,1,41
cbox 68,19,68,60
cfont "XMASK",-2,0,2,20,IFONT,ITEM_JUSTIFY	# item cd
cfont "XMASK",0,0,67,20,IFONT				# desc
cfont 69,20,MAXRCOLS,20,IRFONT			# price

if copy CUSTOMER_COPY,FILE_COPY
	AR_INV_CFONT "XMASK",-2,2,2,60,DBFONT,ITEM_JUSTIFY	# item
	AR_INV_CFONT "XMASK",0,2,67,60,DFONT		# desc
	AR_INV_CFONT 69,22,MAXRCOLS,60,DBRFONT		# price
end if
if copy INTERNAL_COPY
	AR_INV_CFONT "XMASK",-2,2,2,60,DSBFONT,ITEM_JUSTIFY	# item
	AR_INV_CFONT "XMASK",0,2,67,60,DSFONT		# desc
	AR_INV_CFONT 69,22,MAXRCOLS,60,DSBRFONT		# price
	cbox 81,19,100,60,MBOXSIZE
	cbox 81,19,100,21,1,DSHADE
	cbox 93,19,93,60
	cfont 82,20,92,20,IRFONT			# cost
	cfont 94,20,99,20,IRFONT			# gm
	AR_INV_CFONT 82,22,92,60,DSBRFONT		# cost
	AR_INV_CFONT 94,22,99,60,DSBRFONT		# gm
end if

# footer
cerase 36,62,100,62
cerase 36,64,100,64
cerase 36,61,36,64
cerase 48,61,48,63
cerase 58,61,58,63
cerase 67,61,67,63
cerase 93,61,93,63
cbox LEFTCOL,60,MAXCOLS,MAXROWS,MBOXSIZE
cbox 36,60,MAXCOLS,62,1,HSHADE
cbox 36,62,MAXCOLS,64
cbox 48,60,58,64
cbox 67,60,67,64
cfont 37,61,47,61,IBRFONT				# amt
cfont 49,61,57,61,IBRFONT				# tax
cfont 59,61,66,61,IBRFONT				# frt
cfont 68,61,MAXRCOLS,61,IBRFONT,9			# tot due

if copy CUSTOMER_COPY,FILE_COPY
	cfont 37,63,47,63,DBRFONT			# amt
	cfont 49,63,57,63,DBRFONT			# tax
	cfont 59,63,66,63,DBRFONT			# frt
	cfont 68,63,MAXRCOLS,63,DBRFONT,10		# tot due
end if
if copy INTERNAL_COPY
	cfont 37,63,47,63,DSBRFONT			# amt
	cfont 49,63,57,63,DSBRFONT			# tax
	cfont 59,63,66,63,DSBRFONT			# frt
	cfont 68,63,MAXRCOLS,63,DSBRFONT,9		# tot due
	cbox 81,60,100,66,MBOXSIZE
	cbox 81,60,100,62,1,HSHADE
	cbox 81,62,100,64
	cbox 93,60,93,64
	cfont 82,61,92,61,IBRFONT,9			# tot cost
	cfont 94,61,99,61,IRFONT			# gm
	cfont 82,63,92,63,DSBRFONT,9			# tot cost
	cfont 94,63,99,63,DSBRFONT			# gm
end if

if copy CUSTOMER_COPY,FILE_COPY
	cfont 2,61,35,64,DFONT
	cfont 2,65,MAXCOLS,65,DFONT
end if
if copy INTERNAL_COPY
	cfont 2,61,35,64,DSFONT
	cfont 2,65,MAXCOLS,65,DSFONT
end if

#***************************************************************
#              Less frequently used rule sets                  *
#***************************************************************

[A/P Aging Detail]
detect 0,2,"AGED PAYABLES REPORT"
detect 0,0,"PAYMENT   DOCUMENT"

# document options
const MAXCOLS=133
const MAXRCOLS=132
const MAXROWS=63
const LEFTCOL=.5
cols MAXCOLS
rows MAXROWS
landscape

prepage {
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	compname$=trim(get(16,1,x-8-16))
	x$=set(1,1,MAXCOLS,"")

	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	time$=trim(get(x,2,15))
	title$=trim(get(16,2,x-16))
	x$=set(1,2,MAXCOLS,"")
}

# default detail line
cfont 1,1,10,MAXROWS,DRFONT				# vendor code
cfont 12,1,32,MAXROWS,DBFONT				# name
cfont 34,1,41,MAXROWS,DCFONT				# pymt dt
cfont 43,1,52,MAXROWS,DRFONT 				# doc
cfont 54,1,56,MAXROWS,DCFONT				# doc grp
cfont 58,1,65,AXROWS,DCFONT				# ent dt
cfont 67,1,71,MAXROWS,DCFONT				# due dt
cfont 74,1,84,MAXROWS,DPFONT				# current
cfont 86,1,96,MAXROWS,DPFONT				# 1-30
cfont 98,1,108,MAXROWS,DPFONT				# 31-60
cfont 110,1,120,MAXROWS,DPFONT			# 61-90
cfont 122,1,132,MAXROWS,DPFONT			# over 90

# header
cbox LEFTCOL,.5,MAXCOLS,3.25,MBOXSIZE,HSHADE
text 2,1.5,{rptdate$},HBFONT
text 1,1.5,{compname$},HBCFONT,14,cols=MAXCOLS
text 1,1.5,{pageno$},HBRFONT,cols=MAXRCOLS
text 2,2.75,{user$},HBFONT
text 1,2.75,{title$},HBCFONT,12,cols=MAXCOLS
text 1,2.75,{time$},HBRFONT,cols=MAXRCOLS

# subheader
font "~^[A-Z]@1,3",0,0,50,1,IFONT			# rpt opts

# detail
hline "===",erase
erase "-----DATE@59,4,67,7",9,0,5,1
erase "-----DATE@59,4,67,7",0,0,5,1
erase "-----AGING@95,4,104,7",-21,0,58,1
box "VENDOR NAME@5,4,15,8",-4.5,-1.5,132.5,2,1,DSHADE
font "VENDOR@5,4,10,8",0,0,6,1,IRFONT		# vendor
font "NAME@12,4,15,8",0,0,4,1,IFONT			# name
font "PAYMENT@35,4,41,8",0,-1,7,2,ICFONT		# last pymt dt
font "DOCUMENT@45,4,52,8",0,0,8,1,IRFONT		# document
font "GRP@54,4,56,8",0,-1,3,2,ICFONT		# doc grp
font "ENTRY@60,4,64,8",-2,-1,14,1,ICFONT		# dt
font "ENTRY@60,4,64,8",-2,0,8,1,ICFONT		# entry
font "DUE@69,4,71,8",-2,0,5,1,ICFONT		# due
font "CURRENT@77,4,83,8",0,0,7,1,ICFONT		# current
font "CURRENT@77,4,83,8",11,0,8,1,ICFONT		# 1-30
font "CURRENT@77,4,83,8",23,0,8,1,ICFONT		# 31-60
font "CURRENT@77,4,83,8",35,0,8,1,ICFONT		# 61-90
font "CURRENT@77,4,83,8",45,0,10,1,ICFONT		# over 90

# vendor tots
erase "VENDOR TOTAL",0,-1,MAXCOLS,1
font "VENDOR TOTAL",-40,-1,12,1,DBFONT		# phone
font "VENDOR TOTAL",-25,-1,25,1,IFONT		# contact
box "VENDOR TOTAL",-1,-.75,86,1.25,1,DSHADE
box "VENDOR TOTAL",-45,.5,45,1
# purchases line
font "PURCH $@1,7",0,0,7,1,IFONT
font "PURCH $@1,7",9,0,10,1,DBRFONT			# ytd amt
font "PURCH $@1,7",20,0,3,1,IFONT,black		# ytd
font "PURCH $@1,7",25,0,10,1,DBRFONT		# prev yr amt
font "PURCH $@1,7",36,0,3,1,IFONT,black		# pyr

font "VENDOR TOTAL",0,0,12,1,IBFONT
bold "VENDOR TOTAL",0,0,85,A
font "VENDOR TOTAL",13,0,11,1,DBPFONT,10		# bal

# report tots
erase "REPORT TOTAL",0,-1,MAXCOLS,1
box "REPORT TOTAL",-1,-.75,86,1.25,1,HSHADE
font "REPORT TOTAL",0,0,12,1,IBFONT
bold "REPORT TOTAL",0,0,86,1
font "REPORT TOTAL",13,0,11,1,DBPFONT,10		# bal

# footer
font "DOCUMENTS:",0,0,20,1,IBFONT
font "END OF REPORT",0,0,13,1,IBFONT

[A/P Aging Summary]
detect 0,2,"AGED PAYABLES REPORT"
detect 0,0,"PAYMENT     BALANCE"

# document options
const MAXCOLS=115
const MAXRCOLS=114
const MAXROWS=64
const LEFTCOL=.5
cols MAXCOLS
rows MAXROWS
landscape

prepage {
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	compname$=trim(get(16,1,x-8-16))
	x$=set(1,1,MAXCOLS,"")

	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	time$=trim(get(x,2,15))
	title$=trim(get(16,2,x-16))
	x$=set(1,2,MAXCOLS,"")

	# check if extra info printed and set flag to shade
	last_line=0
	for i=4 to MAXROWS
		# undo last flag if summary only
		if last_line>0 and i-last_line=1 and  \
			mid(text$[i],36,1)="/" and \
			mid(text$[i],39,1)="/" then \
			text$[last_line](1,1)="";exitto end_loop
		# set flag if vendor line
		if mid(text$[i],36,1)="/" and \
			mid(text$[i],39,1)="/" then \
			text$[i](1,1)="*";last_line=i
	next i
end_loop:
}

# default detail line
cfont 1,1,10,MAXROWS,DRFONT				# vendor
cfont 12,1,32,MAXROWS,DBFONT				# name
cfont 34,1,41,MAXROWS,DCFONT				# last pymt dt
cfont 43,1,54,MAXROWS,DBPFONT,10			# bal
cfont 56,1,66,MAXROWS,DPFONT				# current
cfont 68,1,78,MAXROWS,DPFONT				# 1-60
cfont 80,1,90,MAXROWS,DPFONT				# 31-60
cfont 92,1,102,MAXROWS,DPFONT				# 61-90
cfont 104,1,114,MAXROWS,DPFONT			# over 90

# header
cbox LEFTCOL,.5,MAXCOLS,3.25,MBOXSIZE,HSHADE
text 2,1.5,{rptdate$},HBFONT
text 1,1.5,{compname$},HBCFONT,14,cols=MAXCOLS
text 1,1.5,{pageno$},HBRFONT,cols=MAXRCOLS
text 2,2.75,{user$},HBFONT
text 1,2.75,{title$},HBCFONT,12,cols=MAXCOLS
text 1,2.75,{time$},HBRFONT,cols=MAXRCOLS

# subheader
font "~[A-Z]@1,4,2,10",0,0,50,1,IFONT		# rpt opts

# detail
erase "AGING@82,4,87,10",-27,0,60,1
erase "VENDOR@5,4,11,10",-4,1,MAXCOLS,1
box "VENDOR@5,4,11,10",-4.5,-1.5,114.5,2,1,DSHADE
font "VENDOR@5,4",0,0,6,1,IRFONT			# vendor
font "NAME@12,4,15,10",0,0,4,1,IFONT		# name
font "PAYMENT@35,4,42,10",0,-1,7,2,ICFONT		# lst pymt dt
font "BALANCE@47,4,54,10",0,0,7,1,ICFONT		# bal
font "BALANCE@47,4,54,10",12,0,7,1,ICFONT		# current
font "BALANCE@47,4,54,10",26,0,5,1,ICFONT		# 1-30
font "BALANCE@47,4,54,10",37,0,6,1,ICFONT		# 31-60
font "BALANCE@47,4,54,10",49,0,6,1,ICFONT		# 61-90
font "BALANCE@47,4,54,10",60,0,7,1,ICFONT		# over 90

# aging line
erase "*@1,1,2,MAXROWS",0,0,1,1
shade "*@1,1,2,MAXROWS",0,0,114.5,1,DSHADE

# phone line
const XMASK=[0-9][0-9][0-9]-[0-9][0-9][0-9]
font "~XMASK@8,7,15",0,0,12,1,DBFONT 		# phone
font "~XMASK@8,7,15",18,0,40,1,IFONT		# contact

# purchases line
font "PURCH $@1,7",0,0,7,1,IFONT
font "PURCH $@1,7",9,0,10,1,DBPFONT			# ytd amt
font "PURCH $@1,7",20,0,3,1,IFONT,black# ytd
font "PURCH $@1,7",25,0,10,1,DBPFONT		# prev yr amt
font "PURCH $@1,7",36,0,3,1,IFONT,black		# pyr

# footer
erase "REPORT TOTAL",0,-1,MAXCOLS,1
box "REPORT TOTAL",-1,-1,86,2,1,HSHADE
font "REPORT TOTAL",0,0,12,1,IBFONT
bold "REPORT TOTAL",0,0,86,1
font "REPORT TOTAL",13,0,11,1,DBPFONT,10		# bal

# footer
font "VENDORS:",0,0,20,1,IBFONT
font "END OF REPORT",0,0,13,1,IBFONT

[A/P Cash Requirements Report]
detect 0,2,"Cash Requirements Report"

# document options
const MAXCOLS=132
const MAXRCOLS=131
const MAXROWS=64
cols MAXCOLS
rows MAXROWS
landscape

prepage {
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	compname$=trim(get(16,1,x-8-16))
	x$=set(1,1,MAXCOLS,"")

	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	time$=trim(get(x,2,15))
	title$=trim(get(16,2,x-16))
	x$=set(1,2,MAXCOLS,"")
}

# header
cbox 1,.5,MAXCOLS,3.25,MBOXSIZE,HSHADE
text 2,1.5,{rptdate$},HBFONT
text 1,1.5,{compname$},HBCFONT,14,cols=MAXCOLS
text 1,1.5,{pageno$},HBRFONT,cols=MAXRCOLS
text 2,2.75,{user$},HBFONT
text 1,2.75,{title$},HBCFONT,12,cols=MAXCOLS
text 1,2.75,{time$},HBRFONT,cols=MAXRCOLS

# detail - do first to not mangle enhancements done below
cfont 1,4,10,MAXROWS,DRFONT				# code
cfont 12,4,41,MAXROWS,DBFONT				# name
cfont 43,4,53,MAXROWS,DBPFONT				# balance
cfont 56,4,66,MAXROWS,DPFONT				# 1st date
cfont 69,4,79,MAXROWS,DPFONT				# 2nd date
cfont 82,4,92,MAXROWS,DPFONT				# 3rd date
cfont 95,4,105,MAXROWS,DPFONT				# 4th date
cfont 108,4,118,MAXROWS,DPFONT			# 5th date
cfont 121,4,131,MAXROWS,DPFONT			# 6th date

# subheader
font "~[A-Z]@1,4,1,6",0,0,50,1,IFONT		# rpt opts

# detail heading
const XMASK="VENDOR NAME@1,4,MAXCOLS,8"
font "XMASK",-4,0,10,1,IRFONT				# code
font "XMASK",7,0,30,1,IFONT				# name
font "XMASK",38,0,11,1,IRFONT				# balance
font "XMASK",51,0,11,1,IRFONT				# 1st date
font "XMASK",64,0,11,1,IRFONT				# 2nd date
font "XMASK",77,0,11,1,IRFONT				# 3rd date
font "XMASK",90,0,11,1,IRFONT				# 4th date
font "XMASK",103,0,11,1,IRFONT			# 5th date
font "XMASK",116,0,11,1,IRFONT			# 6th date
erase "XMASK",0,-1,MAXCOLS,1
hline "=="

# footer
erase "REPORT TOTAL",0,-1,MAXCOLS,1
box "REPORT TOTAL",-1,-1,104,2,1,HSHADE
font "REPORT TOTAL",0,0,12,1,IBFONT
bold "REPORT TOTAL",13,0,MAXCOLS,1			# totals

# footer
font "VENDORS:",0,0,20,1,IBFONT
font "End of Report",0,0,13,1,IBFONT

[A/R Aged Trial Balance Detail]
detect 0,2,"AGED TRIAL BALANCE"
detect 0,0,"DATE     CURRENT"

# document options
const MAXCOLS=134
const MAXRCOLS=133
const MAXROWS=64
const LEFTCOL=.5
cols MAXCOLS
rows MAXROWS
landscape

prepage {
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	compname$=trim(get(16,1,x-8-16))
	x$=set(1,1,MAXCOLS,"")

	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	time$=trim(get(x,2,15))
	title$=trim(get(16,2,x-16))
	x$=set(1,2,MAXCOLS,"")

}

# default aging line
cfont 1,1,10,MAXROWS,DRFONT				# customer
cfont 12,1,36,MAXROWS,DBFONT				# name
cfont 38,1,45,MAXROWS,DCFONT 				# lst Pymt dt
cfont 47,1,52,MAXROWS,DRFONT  			# doc #
cfont 54,1,57,MAXROWS,DCFONT  			# type
cfont 59,1,66,MAXROWS,DCFONT   			# entry dt
cfont 68,1,72,MAXROWS,DCFONT   			# due dt
cfont 74,1,85,MAXROWS,DPFONT  			# current
cfont 87,1,97,MAXROWS,DPFONT  			# 1-60
cfont 99,1,109,MAXROWS,DPFONT  			# 31-60
cfont 111,1,121,MAXROWS,DPFONT  			# 61-90
cfont 123,1,133,MAXROWS,DPFONT  			# over 90

# header
cbox LEFTCOL,.5,MAXCOLS,3.25,MBOXSIZE,HSHADE
text 2,1.5,{rptdate$},HBFONT
text 1,1.5,{compname$},HBCFONT,14,cols=MAXCOLS
text 1,1.5,{pageno$},HBRFONT,cols=MAXRCOLS
text 2,2.75,{user$},HBFONT
text 1,2.75,{title$},HBCFONT,12,cols=MAXCOLS
text 1,2.75,{time$},HBRFONT,cols=MAXRCOLS

# subheader
font "~^[A-Z]@1,4,1,5",0,0,MAXCOLS,1,IFONT		# rpt opts

# detail heading
erase "CUSTOMER NAME@3,5,15,7",-2,1,MAXCOLS,1
box   "CUSTOMER NAME@3,5,15,7",-2.5,-1.5,133.5,2,1,DSHADE
font  "CUSTOMER NAME@3,5,15,7",0,0,8,1,IRFONT		# customer
font  "CUSTOMER NAME@3,5,15,7",9,0,4,1,IFONT		# name
font  "PAYMENT@39,5,45,7",-1,-1,8,2,ICFONT		# lst pymt dt
font  "DOC#@49,5,52,7",-2,0,6,1,IRFONT			# doc #
font  "TYPE@54,5,57,7",0,0,4,1,ICFONT			# type
font  "DATE    DATE@61,5,72,7",-2,-1,8,2,ICFONT		# entry dt
font  "DATE    DATE@61,5,72,7",7,-1,5,2,ICFONT		# due   dt
font  "CURRENT@78,5,84,7",-3,0,10,1,ICFONT		# current
font  "CURRENT@78,5,84,7",9,0,10,1,ICFONT			# 1-30
font  "CURRENT@78,5,84,7",21,0,10,1,ICFONT		# 31-60
font  "CURRENT@78,5,84,7",33,0,10,1,ICFONT		# 61-90
font  "CURRENT@78,5,84,7",45,0,10,1,ICFONT		# over 90

# returns pending
font "*Returns Pending Credit*@12,7",0,0,24,1,IFONT

# customer tots
erase "CUSTOMER TOTAL",0,-1,MAXCOLS,1
box "CUSTOMER TOTAL",-1,-.75,88,1.5,1,ISHADE
box "CUSTOMER TOTAL",-46.5,.75,47,1
font "CUSTOMER TOTAL",-40,-1,15,1,DBFONT		# phone
font "CUSTOMER TOTAL",-23,-1,24,1,IFONT		# contact
font "CUSTOMER TOTAL",-39,0,6,1,IFONT		# sales:
font "CUSTOMER TOTAL",-32,0,11,1,DBRFONT		# ytd amt
font "CUSTOMER TOTAL",-20,0,3,1,IFONT		# ytd
font "CUSTOMER TOTAL",-16,0,11,1,DBRFONT		# prev yr amt
font "CUSTOMER TOTAL",-4,0,3,1,IFONT		# pyr

font "CUSTOMER TOTAL",0,0,14,1,IBFONT
bold "CUSTOMER TOTAL",0,0,88,1
font "CUSTOMER TOTAL",15,0,11,1,DBPFONT,10	# bal

# report tots
erase "REPORT TOTAL",0,-1,MAXCOLS,1
box "REPORT TOTAL",-3,-.75,88,1.5,1,HSHADE
font "REPORT TOTAL",0,0,12,1,IBFONT
bold "REPORT TOTAL",0,0,88,1
font "REPORT TOTAL",13,0,11,1,DBPFONT,10		# bal

# footer
font "Customers:",0,0,20,1,IBFONT
font "End of Report",0,0,13,1,IBFONT

[A/R Aged Trial Balance Summary]
detect 0,2,"AGED TRIAL BALANCE"
detect 0,0,"BALANCE     CURRENT"

# document options
const MAXCOLS=128
const MAXRCOLS=127
const MAXROWS=64
const LEFTCOL=.5
cols MAXCOLS
rows MAXROWS
landscape

prepage {
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	compname$=trim(get(16,1,x-8-16))
	x$=set(1,1,MAXCOLS,"")

	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	time$=trim(get(x,2,15))
	title$=trim(get(16,2,x-16))
	x$=set(1,2,MAXCOLS,"")
}

# detail line
cfont 1,1,10,MAXROWS,DRFONT			# customer
cfont 12,1,36,MAXROWS,DBFONT			# name
cfont 38,1,45,MAXROWS,DCFONT			# lst pymt dt
cfont 47,1,54,MAXROWS,DCFONT			# lst sale dt
cfont 56,1,68,MAXROWS,DBPFONT			# bal
cfont 69,1,80,MAXROWS,DPFONT			# current
cfont 82,1,92,MAXROWS,DPFONT			# 1-60
cfont 94,1,104,MAXROWS,DPFONT			# 31-60
cfont 106,1,116,MAXROWS,DPFONT		# 61-90
cfont 118,1,128,MAXROWS,DPFONT		# over 90

# header
cbox LEFTCOL,.5,MAXCOLS,3.25,3,HSHADE
text 2,1.5,{rptdate$},HBFONT
text 1,1.5,{compname$},HBCFONT,14,cols=MAXCOLS
text 1,1.5,{pageno$},HBRFONT,cols=MAXRCOLS
text 2,2.75,{user$},HBFONT
text 1,2.75,{title$},HBCFONT,12,cols=MAXCOLS
text 1,2.75,{time$},HBRFONT,cols=MAXRCOLS

# subheader
font "~^[A-Z]@1,4",0,0,MAXCOLS,1,IFONT			# rpt opts

# detail heading
erase "CUSTOMER NAME@3,4,15,10",-2,1,MAXCOLS,1
box "CUSTOMER NAME@3,4,15,10",-2.5,-1.5,127.5,2,1,DSHADE
font "CUSTOMER NAME@3,4,15,10",0,0,8,1,IRFONT		# customer
font "CUSTOMER NAME@3,4,15,10",9,0,4,1,IFONT		# name
font "PAYMENT@39,4,45,10",-1,-1,8,2,ICFONT		# lst pymt dt
font "SALE@49,4,52,10",-2,-1,8,2,ICFONT			# lst sale dt
font "BALANCE@61,4,67,10",0,0,7,1,ICFONT			# bal
font "BALANCE@61,4,67,10",10,0,10,1,ICFONT		# current
font "BALANCE@61,4,67,10",22,0,10,1,ICFONT		# 1-30
font "BALANCE@61,4,67,10",34,0,10,1,ICFONT		# 31-60
font "BALANCE@61,4,67,10",46,0,10,1,ICFONT		# 61-90
font "BALANCE@61,4,67,10",58,0,10,1,ICFONT		# over 90

# returns pending
font "*Returns Pending Credit*@12,7",0,0,24,1,IFONT

# phone line
const XMASK=[0-9][0-9][0-9]
font "~XMASK@12,7,14",0,0,12,1,DBFONT			# phone #
font "~XMASK@12,7,14",18,0,40,1,IFONT			# contact

# sales line
font "Sales:@12,7",0,0,6,1,IFONT
font "Sales:@12,7",7,0,11,1,DBPFONT				# ytd amt
font "Sales:@12,7",19,0,3,1,IFONT				# ytd
font "Sales:@12,7",23,0,11,1,DBPFONT			# prev yr amt
font "Sales:@12,7",35,0,3,1,IFONT				# pyr

# footer
erase "REPORT TOTAL",0,-1,MAXCOLS,1
box "REPORT TOTAL",-1,-1,85,2,1,HSHADE
font "REPORT TOTAL",0,0,12,1,IBFONT
bold "REPORT TOTAL",0,0,85,1
font "REPORT TOTAL",13,0,11,1,DBPFONT,10		# bal

# footer
font "Customers:",0,0,20,1,IBFONT
font "End of Report",0,0,13,1,IBFONT

[A/R Aged Trial Balance Transactions]
detect 0,2,"AGED TRIAL BALANCE"
detect 0,0,"AMOUNT      CURRENT"

# document options
const MAXCOLS=130
const MAXRCOLS=129
const MAXROWS=61
const LEFTCOL=.5
cols MAXCOLS
rows MAXROWS
landscape

prepage {
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	compname$=trim(get(16,1,x-8-16))
	x$=set(1,1,MAXCOLS,"")

	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	time$=trim(get(x,2,15))
	title$=trim(get(16,2,x-16))
	x$=set(1,2,MAXCOLS,"")

}

# default detail line
cfont 1,1,6,MAXROWS,DRFONT				# doc #
cfont 8,1,11,MAXROWS,DCFONT				# type
cfont 13,1,20,MAXROWS,DCFONT				# entry dt
cfont 22,1,29,MAXROWS,DCFONT				# due dt
cfont 31,1,41,MAXROWS,DPFONT				# orig amt
cfont 43,1,50,MAXROWS,DCFONT				# trs dt
cfont 52,1,55,MAXROWS,DCFONT				# trs type
cfont 57,1,68,MAXROWS,DPFONT				# trs amt
cfont 70,1,81,MAXROWS,DPFONT				# current
cfont 83,1,93,MAXROWS,DPFONT				# 1-60
cfont 95,1,105,MAXROWS,DPFONT				# 31-60
cfont 107,1,117,MAXROWS,DPFONT			# 61-90
cfont 119,1,129,MAXROWS,DPFONT			# over 90

# header
cbox LEFTCOL,.5,MAXCOLS,3.25,3,HSHADE
text 2,1.5,{rptdate$},HBFONT
text 1,1.5,{compname$},HBCFONT,14,cols=MAXCOLS
text 1,1.5,{pageno$},HBRFONT,cols=MAXRCOLS
text 2,2.75,{user$},HBFONT
text 1,2.75,{title$},HBCFONT,12,cols=MAXCOLS
text 1,2.75,{time$},HBRFONT,cols=MAXRCOLS

# subheader
font "~^[A-Z]@1,4,1,5",0,0,MAXCOLS,1,IFONT		# rpt opts

# detail heading
hline "===",erase
erase "DOC# TYPE@3,5,11,8",-2,1,MAXCOLS,1
erase "-------@1,4,70,7",0,0,7,1
box "DOC# TYPE@3,5,11,8",-2.5,-1.5,129.5,2,1,DSHADE
font "DOC#@3,5,6,8",-2,0,6,1,IRFONT				# doc #
font "DOC# TYPE@3,5,11,8",5,0,4,1,ICFONT			# type
font "DATE     DATE@15,5,27,8",-2,-1,8,2,ICFONT		# entry dt
font "DATE     DATE@15,5,27,8",8,-1,5,2,ICFONT		# due   dt
font "AMOUNT   DATE@36,5,48,8",-5,-1,11,2,ICFONT	# orig amt
font "DATE   TYPE@45,5,55,8",-2,-1,25,1,ICFONT		# trs hdr
font "DATE   TYPE@45,5,55,8",-2,0,8,1,ICFONT		# trs dt
font "DATE   TYPE@45,5,55,8",7,0,4,1,ICFONT		# trs type
font "DATE   TYPE@45,5,55,8",12,0,11,1,IRFONT		# trs amt
font "CURRENT@74,5,80,8",-3,0,10,1,ICFONT			# current
font "CURRENT@74,5,80,8",10,0,10,1,ICFONT			# 1-30
font "CURRENT@74,5,80,8",22,0,10,1,ICFONT			# 31-60
font "CURRENT@74,5,80,8",34,0,10,1,ICFONT			# 61-90
font "CURRENT@74,5,80,8",46,0,10,1,ICFONT			# over 90

# Customer line
font "~^Customer:",0,0,9,1,DFONT
font "~^Customer:",10,0,10,1,DRFONT
font "~^Customer:",21,0,30,1,DBFONT
font "~^Customer:",53,0,25,1,DFONT
font "~^Customer:",0,1,MAXCOLS,1,DFONT

# customer tots
erase "CUSTOMER TOTAL",0,-1,MAXCOLS,1
box "CUSTOMER TOTAL",-1,-.75,76,1.25,1,ISHADE
box "CUSTOMER TOTAL",-54.5,.5,53.5,1
font "CUSTOMER TOTAL",0,0,14,1,IBFONT
bold "CUSTOMER TOTAL",0,0,76,1

# report tots
erase "REPORT TOTAL",0,-1,MAXCOLS,1
box "REPORT TOTAL",-3,-.75,76,1.5,1,HSHADE
font "REPORT TOTAL",0,0,12,1,IBFONT
bold "REPORT TOTAL",0,0,76,1

# footer
font "Customers:",0,0,20,1,IBFONT
font "End of Report",0,0,13,1,IBFONT

[G/L Profit & Loss 820/828]
detect 0,1,"~(GLR820)|(GLR828)"

# document options
const MAXCOLS=133
const MAXRCOLS=132
const MAXROWS=58
const LEFTCOL=1
cols MAXCOLS
rows MAXROWS
landscape

prepage {
	head1$="",head2$="",head3$="",head4$=""
	head5$="",head6$="",head7$="",head8$=""

	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	head1$=trim(get(16,1,x-8-15))
	pageno=num(trim(get(x+4,1,3)))
	head2$=trim(get(1,2,MAXCOLS))
	if head2$(1,5)<>"AS OF" then \
		head3$=trim(get(1,3,MAXCOLS)); \
		head4$=trim(get(1,4,MAXCOLS)); \
		head5$=trim(get(1,5,MAXCOLS)); \
		head6$=trim(get(1,6,MAXCOLS)); \
		head7$=trim(get(1,7,MAXCOLS)); \
		head8$=trim(get(1,8,MAXCOLS))
	# handle different box sizes on heading
	if pageno=1 then xrow$="7.75" else xrow$="1.75"
	x$="cbox LEFTCOL,.5,MAXCOLS,"+xrow$+",MBOXSIZE,HSHADE"
	exec(x$)

	# erase headings
	if pageno=1 then end_row=8 else end_row=2
	for i=1 to end_row
		x$=set(1,i,MAXCOLS,"")
	next i

}

# default detail line
cfont 1,1,16,MAXROWS,DPFONT			# period end
cfont 18,1,25,MAXROWS,DPFONT			# %
cfont 27,1,41,MAXROWS,DPFONT			# period end
cfont 43,1,50,MAXROWS,DPFONT			# %
cfont 52,1,81,MAXROWS,DBFONT			# desc
cfont 83,1,97,MAXROWS,DPFONT			# ytd
cfont 99,1,107,MAXROWS,DPFONT			# %
cfont 109,1,123,MAXROWS,DPFONT		# ytd
cfont 125,1,MAXRCOLS,MAXROWS,DPFONT		# %

# header
# note: on pages after 1, only head2$ will have text
text 2,1.25,{rptdate$},HBFONT
text 1,1.25,{pageno$},HBRFONT,cols=MAXRCOLS
text 1,1.25,{head2$},HBCFONT,12,cols=MAXRCOLS
text 1,2.25,{head3$},HBCFONT,12,cols=MAXRCOLS
text 1,3.25,{head4$},HBCFONT,11,cols=MAXRCOLS
text 1,4.25,{head5$},HCFONT,11,cols=MAXRCOLS
text 1,5.25,{head6$},HCFONT,11,cols=MAXRCOLS
text 1,6.25,{head7$},HCFONT,11,cols=MAXRCOLS
text 1,7.25,{head8$},HCFONT,11,cols=MAXRCOLS

# detail heading
hline "==",erase
box "~^===",0,-2.5,132,2,1,DSHADE
font "PERIOD ",-1,0,12,2,IPFONT
font "BUDGET",0,0,6,1,IPFONT
font "PERCENT",0,0,7,1,IPFONT
font "YEAR TO  ",-1,0,9,2,IPFONT
font "YEAR TO DATE",0,-1,12,2,IPFONT

# detail
font "~^[A-Z0-9]@1,6",0,0,MAXCOLS,1,DBFONT	# acnt desc
font "  Revenues",2,0,8,1,DBCFONT,11
font "  Cost of Sales",2,0,13,1,DBCFONT,11
font "  General & Admin",2,0,33,1,DBCFONT,11

# footer
erase "~^ -----",0,0,MAXCOLS,1
bold "~^ -----",0,1,MAXCOLS,2
box "Total Revenues",-51,-.6,132,1.1,1,DSHADE
box "Total Cost of Sales",-51,-.6,132,1.1,1,DSHADE
box "Gross Profit",-51,-.6,132,1.1,1,ISHADE
box "Total General & Admin",-51,-.6,132,2.1,1,DSHADE
box "Net Profit or Loss",-51,-.6,132,1.1,1,HSHADE

[G/L Profit & Loss 822/824/826/834/836/842]
detect 0,1,"~(GLR822)|(GLR824)|(GLR826)|(GLR834)|(GLR836)|(GLR842)"

# document options
const MAXCOLS=106
const MAXRCOLS=105
const MAXROWS=58
const LEFTCOL=.5
cols MAXCOLS
rows MAXROWS
landscape

prepage {
	head1$="",head2$="",head3$="",head4$=""
	head5$="",head6$="",head7$="",head8$=""

	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	head1$=trim(get(16,1,x-8-15))
	pageno=num(trim(get(x+4,1,3)))
	head2$=trim(get(1,2,MAXCOLS))
	if head2$(1,5)<>"AS OF" then \
		head3$=trim(get(1,3,MAXCOLS)); \
		head4$=trim(get(1,4,MAXCOLS)); \
		head5$=trim(get(1,5,MAXCOLS)); \
		head6$=trim(get(1,6,MAXCOLS)); \
		head7$=trim(get(1,7,MAXCOLS)); \
		head8$=trim(get(1,8,MAXCOLS))
	# handle different box sizes on heading
	if pageno=1 then xrow$="7.75" else xrow$="1.75"
	x$="cbox LEFTCOL,.5,MAXCOLS,"+xrow$+",MBOXSIZE,HSHADE"
	exec(x$)

	# erase headings
	if pageno=1 then end_row=8 else end_row=2
	for i=1 to end_row
		x$=set(1,i,MAXCOLS,"")
	next i

}

# default detail line
cfont 1,1,30,MAXROWS,DBFONT			# desc
cfont 32,1,46,MAXROWS,DPFONT			# period end
cfont 48,1,55,MAXROWS,DPFONT			# %
cfont 57,1,71,MAXROWS,DPFONT			# period end last yr
cfont 73,1,80,MAXROWS,DPFONT			# %
cfont 82,1,96,MAXROWS,DPFONT			# var amt
cfont 98,1,105,MAXROWS,DPFONT			# var pct

# header
# note: on pages after 1, only head2$ will have text
text 2,1.25,{rptdate$},HBFONT
text 1,1.25,{pageno$},HBRFONT,cols=MAXRCOLS
text 1,1.25,{head2$},HBCFONT,12,cols=MAXRCOLS
text 1,2.25,{head3$},HBCFONT,12,cols=MAXRCOLS
text 1,3.25,{head4$},HBCFONT,11,cols=MAXRCOLS
text 1,4.25,{head5$},HCFONT,11,cols=MAXRCOLS
text 1,5.25,{head6$},HCFONT,11,cols=MAXRCOLS
text 1,6.25,{head7$},HCFONT,11,cols=MAXRCOLS
text 1,7.25,{head8$},HCFONT,11,cols=MAXRCOLS

# detail heading
hline "==",erase
box "~^===",-.5,-2.5,105.5,2,1,DSHADE
font "BUDGET",0,0,6,1,IRFONT
font "YR TO DATE",0,0,10,1,IRFONT
font "PERCENT",0,0,7,1,IRFONT
font "VARIANCE",-4,0,16,1,ICFONT
font "AMOUNT",0,0,6,1,IRFONT
font "ENDING ",0,-1,12,2,IRFONT

# detail
font "  Revenues",2,0,8,1,DBCFONT,11
font "  Cost of Sales",2,0,13,1,DBCFONT,11
font "  General & Admin",2,0,33,1,DBCFONT,11

# footer
erase "~^(Total)|(Gross Profit)|(Net Profit)",0,-1,MAXCOLS,1
bold "~^(Total)|(Gross Profit)|(Net Profit)",0,0,MAXCOLS,2
box "Total Revenues",-.5,-.6,105.5,1.1,1,DSHADE
box "Total Cost of Sales",-.5,-.6,105.5,1.1,1,DSHADE
box "Gross Profit",-.5,-.6,105.5,1.1,1,ISHADE
box "Total General & Admin",-.5,-.6,105.5,2.1,1,DSHADE
box "Net Profit or Loss",-.5,-.6,105.5,1.1,1,HSHADE

[G/L Profit & Loss 830]
detect 0,1,"GLR830"

# document options
const MAXCOLS=133
const MAXRCOLS=132
const MAXROWS=58
const LEFTCOL=1
cols MAXCOLS
rows MAXROWS
landscape

prepage {
	head1$="",head2$="",head3$="",head4$=""
	head5$="",head6$="",head7$="",head8$=""

	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	head1$=trim(get(16,1,x-8-15))
	pageno=num(trim(get(x+4,1,3)))
	head2$=trim(get(1,2,MAXCOLS))
	if head2$(1,5)<>"AS OF" then \
		head3$=trim(get(1,3,MAXCOLS)); \
		head4$=trim(get(1,4,MAXCOLS)); \
		head5$=trim(get(1,5,MAXCOLS)); \
		head6$=trim(get(1,6,MAXCOLS)); \
		head7$=trim(get(1,7,MAXCOLS)); \
		head8$=trim(get(1,8,MAXCOLS))
	# handle different box sizes on heading
	if pageno=1 then xrow$="7.75" else xrow$="1.75"
	x$="cbox LEFTCOL,.5,MAXCOLS,"+xrow$+",MBOXSIZE,HSHADE"
	exec(x$)

	# erase headings
	if pageno=1 then end_row=8 else end_row=2
	for i=1 to end_row
		x$=set(1,i,MAXCOLS,"")
	next i

}

# default detail line
cfont 1,1,13,MAXROWS,DPFONT			# period end
cfont 15,1,27,MAXROWS,DPFONT			# budget
cfont 29,1,41,MAXROWS,DPFONT			# var amt
cfont 43,1,50,MAXROWS,DPFONT			# var %
cfont 52,1,81,MAXROWS,DBFONT			# desc
cfont 83,1,95,MAXROWS,DPFONT			# ytd
cfont 97,1,109,MAXROWS,DPFONT			# budget ytd
cfont 111,1,123,MAXROWS,DPFONT		# var amt
cfont 125,1,MAXRCOLS,MAXROWS,DPFONT		# var %

# header
# note: on pages after 1, only head2$ will have text
text 2,1.25,{rptdate$},HBFONT
text 1,1.25,{pageno$},HBRFONT,cols=MAXRCOLS
text 1,1.25,{head2$},HBCFONT,12,cols=MAXRCOLS
text 1,2.25,{head3$},HBCFONT,12,cols=MAXRCOLS
text 1,3.25,{head4$},HBCFONT,11,cols=MAXRCOLS
text 1,4.25,{head5$},HCFONT,11,cols=MAXRCOLS
text 1,5.25,{head6$},HCFONT,11,cols=MAXRCOLS
text 1,6.25,{head7$},HCFONT,11,cols=MAXRCOLS
text 1,7.25,{head8$},HCFONT,11,cols=MAXRCOLS

# detail heading
hline "==",erase
box "~^===",0,-2.5,132,2,1,DSHADE
font "PERIOD ",-1,0,12,2,IPFONT
font "BUDGET",0,0,6,1,IPFONT
font "VARIANCE",-4,0,16,1,ICFONT
font "AMOUNT",0,0,6,1,IPFONT
font "PERCENT",0,0,7,1,IPFONT
font "YEAR TO  ",-1,0,9,2,IPFONT
font "YR TO DATE",0,-1,10,2,IPFONT

# detail
font "  Revenues",2,0,8,1,DBCFONT,11
font "  Cost of Sales",2,0,13,1,DBCFONT,11
font "  General & Admin",2,0,33,1,DBCFONT,11

# footer
erase "~^ -----",0,0,MAXCOLS,1
bold "~^ -----",0,1,MAXCOLS,2
box "Total Revenues",-51,-.6,132,1.1,1,DSHADE
box "Total Cost of Sales",-51,-.6,132,1.1,1,DSHADE
box "Gross Profit",-51,-.6,132,1.1,1,ISHADE
box "Total General & Admin",-51,-.6,132,2.1,1,DSHADE
box "Net Profit or Loss",-51,-.6,132,1.1,1,HSHADE

[G/L Profit & Loss 832]
detect 0,1,"GLR832"

# document options
const MAXCOLS=100
const MAXRCOLS=99
const MAXROWS=58
const LEFTCOL=1
cols MAXCOLS
rows MAXROWS
landscape

prepage {
	head1$="",head2$="",head3$="",head4$=""
	head5$="",head6$="",head7$="",head8$=""

	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	head1$=trim(get(16,1,x-8-15))
	pageno=num(trim(get(x+4,1,3)))
	head2$=trim(get(1,2,MAXCOLS))
	if head2$(1,5)<>"AS OF" then \
		head3$=trim(get(1,3,MAXCOLS)); \
		head4$=trim(get(1,4,MAXCOLS)); \
		head5$=trim(get(1,5,MAXCOLS)); \
		head6$=trim(get(1,6,MAXCOLS)); \
		head7$=trim(get(1,7,MAXCOLS)); \
		head8$=trim(get(1,8,MAXCOLS))
	# handle different box sizes on heading
	if pageno=1 then xrow$="7.75" else xrow$="1.75"
	x$="cbox LEFTCOL,.5,MAXCOLS,"+xrow$+",MBOXSIZE,HSHADE"
	exec(x$)

	# erase headings
	if pageno=1 then end_row=8 else end_row=2
	for i=1 to end_row
		x$=set(1,i,MAXCOLS,"")
	next i

}

# default detail line
cfont 1,1,16,MAXROWS,DPFONT			# period end
cfont 18,1,33,MAXROWS,DPFONT			# prev period end
cfont 36,1,65,MAXROWS,DBFONT			# desc
cfont 67,1,83,MAXROWS,DPFONT			# ytd
cfont 85,1,99,MAXROWS,DPFONT			# prev ytd

# header
# note: on pages after 1, only head2$ will have text
text 2,1.25,{rptdate$},HBFONT
text 1,1.25,{pageno$},HBRFONT,cols=MAXRCOLS
text 1,1.25,{head2$},HBCFONT,12,cols=MAXRCOLS
text 1,2.25,{head3$},HBCFONT,12,cols=MAXRCOLS
text 1,3.25,{head4$},HBCFONT,11,cols=MAXRCOLS
text 1,4.25,{head5$},HCFONT,11,cols=MAXRCOLS
text 1,5.25,{head6$},HCFONT,11,cols=MAXRCOLS
text 1,6.25,{head7$},HCFONT,11,cols=MAXRCOLS
text 1,7.25,{head8$},HCFONT,11,cols=MAXRCOLS

# detail heading
hline "==",erase
box "~^===",0,-2.5,99,2,1,DSHADE
font "PERIOD ",-1,0,12,2,IPFONT
font "YEAR TO  ",-1,0,9,2,IPFONT

# detail
font "  Revenues",2,0,8,1,DBCFONT,11
font "  Cost of Sales",2,0,13,1,DBCFONT,11
font "  General & Admin",2,0,33,1,DBCFONT,11

# footer
erase "~^ -----",0,0,MAXCOLS,1
bold "~^ -----",0,1,MAXCOLS,2
box "Total Revenues",-51,-.6,99,1.1,1,DSHADE
box "Total Cost of Sales",-51,-.6,99,1.1,1,DSHADE
box "Gross Profit",-51,-.6,99,1.1,1,ISHADE
box "Total General & Admin",-51,-.6,99,2.1,1,DSHADE
box "Net Profit or Loss",-51,-.6,99,1.1,1,HSHADE

[G/L Profit & Loss 838]
detect 0,1,"GLR838"

# document options
const MAXCOLS=87
const MAXRCOLS=86
const MAXROWS=66
const LEFTCOL=1
cols MAXCOLS
rows MAXROWS

prepage {
	head1$="",head2$="",head3$="",head4$=""
	head5$="",head6$="",head7$="",head8$=""

	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	head1$=trim(get(16,1,x-8-15))
	pageno=num(trim(get(x+4,1,3)))
	head2$=trim(get(1,2,MAXCOLS))
	if head2$(1,5)<>"AS OF" then \
		head3$=trim(get(1,3,MAXCOLS)); \
		head4$=trim(get(1,4,MAXCOLS)); \
		head5$=trim(get(1,5,MAXCOLS)); \
		head6$=trim(get(1,6,MAXCOLS)); \
		head7$=trim(get(1,7,MAXCOLS)); \
		head8$=trim(get(1,8,MAXCOLS))
	# handle different box sizes on heading
	if pageno=1 then xrow$="7.75" else xrow$="1.75"
	x$="cbox LEFTCOL,.5,MAXCOLS,"+xrow$+",MBOXSIZE,HSHADE"
	exec(x$)

	# erase headings
	if pageno=1 then end_row=8 else end_row=2
	for i=1 to end_row
		x$=set(1,i,MAXCOLS,"")
	next i

}

# default detail line
cfont 1,1,16,MAXROWS,DPFONT			# period end
cfont 18,1,26,MAXROWS,DPFONT			# %
cfont 29,1,58,MAXROWS,DBFONT			# desc
cfont 60,1,76,MAXROWS,DPFONT			# ytd
cfont 78,1,86,MAXROWS,DPFONT			# %

# header
# note: on pages after 1, only head2$ will have text
text 2,1.25,{rptdate$},HBFONT
text 1,1.25,{pageno$},HBRFONT,cols=MAXRCOLS
text 1,1.25,{head2$},HBCFONT,12,cols=MAXRCOLS
text 1,2.25,{head3$},HBCFONT,12,cols=MAXRCOLS
text 1,3.25,{head4$},HBCFONT,11,cols=MAXRCOLS
text 1,4.25,{head5$},HCFONT,11,cols=MAXRCOLS
text 1,5.25,{head6$},HCFONT,11,cols=MAXRCOLS
text 1,6.25,{head7$},HCFONT,11,cols=MAXRCOLS
text 1,7.25,{head8$},HCFONT,11,cols=MAXRCOLS

# detail heading
hline "==",erase
box "~^===",0,-2.5,86,2.2,1,DSHADE
font "PERIOD ",-1,0,12,2,IFONT
font "PERCENT",0,0,7,1,IFONT
font "YEAR TO",-1,0,9,2,IFONT

# detail
font "  Revenues",2,0,8,1,DBCFONT,11
font "  Cost of Sales",2,0,13,1,DBCFONT,11
font "  General & Admin",2,0,33,1,DBCFONT,11

# footer
erase "~^ -----",0,0,MAXCOLS,1
bold "~^ -----",0,1,MAXCOLS,2
box "Total Revenues",-51,-.6,86,1.1,1,DSHADE
box "Total Cost of Sales",-51,-.6,86,1.1,1,DSHADE
box "Gross Profit",-51,-.6,86,1.1,1,ISHADE
box "Total General & Admin",-51,-.6,86,2.1,1,DSHADE
box "Net Profit or Loss",-51,-.6,86,1.1,1,HSHADE

[G/L Profit & Loss 840/848]
detect 0,1,"~(GLR840)|(GLR848)"

# document options
const MAXCOLS=132
const MAXRCOLS=131
const MAXROWS=58
const LEFTCOL=.5
cols MAXCOLS
rows MAXROWS
landscape
pcopies 1

prepage {
	head1$="",head2$="",head3$="",head4$=""
	head5$="",head6$="",head7$="",head8$=""

	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	head1$=trim(get(16,1,x-8-15))
	pageno=num(trim(get(x+4,1,3)))
	head2$=trim(get(1,2,MAXCOLS))
	head3$=trim(get(1,3,MAXCOLS))
	if head3$<>"" then \
		head4$=trim(get(1,4,MAXCOLS)); \
		head5$=trim(get(1,5,MAXCOLS)); \
		head6$=trim(get(1,6,MAXCOLS)); \
		head7$=trim(get(1,7,MAXCOLS)); \
		head8$=trim(get(1,8,MAXCOLS))
	# handle different box sizes on heading
	if pageno=1 then xrow$="7.75" else xrow$="1.75"
	x$="cbox LEFTCOL,.5,MAXCOLS,"+xrow$+",MBOXSIZE,HSHADE"
	exec(x$)

	# erase headings
	if pageno=1 then end_row=8 else end_row=3
	for i=1 to end_row
		x$=set(1,i,MAXCOLS,"")
	next i
}

# default detail line
cfont 2,1,10,MAXROWS,DPFONT			# 1st period
cfont 12,1,21,MAXROWS,DPFONT			# 2nd period
cfont 23,1,32,MAXROWS,DPFONT			# 3rd period
cfont 34,1,43,MAXROWS,DPFONT			# 4th period
cfont 45,1,54,MAXROWS,DPFONT			# 5th period
cfont 56,1,65,MAXROWS,DPFONT			# 6th period
cfont 67,1,76,MAXROWS,DPFONT			# 7th period
cfont 78,1,87,MAXROWS,DPFONT			# 8th period
cfont 89,1,98,MAXROWS,DPFONT			# 9th period
cfont 100,1,109,MAXROWS,DPFONT		# 10th period
cfont 111,1,120,MAXROWS,DPFONT		# 11th period
cfont 122,1,131,MAXROWS,DPFONT		# 12th period

# header
# note: on pages after 1, only head2$ will have text
text 2,1.25,{rptdate$},HBFONT
text 1,1.25,{pageno$},HBRFONT,cols=MAXRCOLS
text 1,1.25,{head2$},HBCFONT,12,cols=MAXRCOLS
text 1,2.25,{head3$},HBCFONT,12,cols=MAXRCOLS
text 1,3.25,{head4$},HBCFONT,11,cols=MAXRCOLS
text 1,4.25,{head5$},HCFONT,11,cols=MAXRCOLS
text 1,5.25,{head6$},HCFONT,11,cols=MAXRCOLS
text 1,6.25,{head7$},HCFONT,11,cols=MAXRCOLS
text 1,7.25,{head8$},HCFONT,11,cols=MAXRCOLS

# detail heading
hline "==",erase
box "~^===",-1.5,-1.8,131.5,1.4,1,DSHADE
const XMASK=[0-9][0-9]/[0-9][0-9]
font "~XMASK@1,4,MAXCOLS,10",0,0,9,1,IRFONT 		# dt

# detail
font "~^[A-Z0-9]@1,6",0,0,MAXCOLS,1,DBFONT	# acnt desc
font "  Revenues",2,0,8,1,DBCFONT,11
font "  Cost of Sales",2,0,13,1,DBCFONT,11
font "  General & Admin",2,0,33,1,DBCFONT,11

# footer
erase "~^ -----",0,0,MAXCOLS,1
bold "~^ -----",0,1,MAXCOLS,2
box "~^Total",-1.5,-.8,MAXCOLS,2.4,1,DSHADE
box "~^Gross Profit",-1.5,-.8,MAXCOLS,2.4,1,ISHADE
box "~^Net Profit",-1.5,-.8,MAXCOLS,2.4,1,HSHADE

[G/L Profit & Loss 844]
detect 0,1,"GLR844"

# document options
const MAXCOLS=133
const MAXRCOLS=132
const MAXROWS=58
const LEFTCOL=.5
cols MAXCOLS
rows MAXROWS
landscape

prepage {
	head1$="",head2$="",head3$="",head4$=""
	head5$="",head6$="",head7$="",head8$=""

	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	head1$=trim(get(16,1,x-8-15))
	pageno=num(trim(get(x+4,1,3)))
	head2$=trim(get(1,2,MAXCOLS))
	if head2$(1,5)<>"AS OF" then \
		head3$=trim(get(1,3,MAXCOLS)); \
		head4$=trim(get(1,4,MAXCOLS)); \
		head5$=trim(get(1,5,MAXCOLS)); \
		head6$=trim(get(1,6,MAXCOLS)); \
		head7$=trim(get(1,7,MAXCOLS)); \
		head8$=trim(get(1,8,MAXCOLS))
	# handle different box sizes on heading
	if pageno=1 then xrow$="7.75" else xrow$="1.75"
	x$="cbox LEFTCOL,.5,MAXCOLS,"+xrow$+",MBOXSIZE,HSHADE"
	exec(x$)

	# erase headings
	if pageno=1 then end_row=8 else end_row=2
	for i=1 to end_row
		x$=set(1,i,MAXCOLS,"")
	next i

}

# default detail line
cfont 1,1,17,MAXROWS,DBFONT			# desc
cfont 19,1,28,MAXROWS,DRFONT			# 1st period
cfont 30,1,36,MAXROWS,DRFONT			# %
cfont 38,1,47,MAXROWS,DRFONT			# 2nd period
cfont 49,1,56,MAXROWS,DRFONT			# %
cfont 58,1,67,MAXROWS,DRFONT			# 3rd period
cfont 69,1,75,MAXROWS,DRFONT			# %
cfont 77,1,86,MAXROWS,DRFONT			# 4th period
cfont 88,1,94,MAXROWS,DRFONT			# %
cfont 96,1,105,MAXROWS,DRFONT			# 5th period
cfont 107,1,113,MAXROWS,DRFONT		# %
cfont 115,1,124,MAXROWS,DRFONT		# 6th period
cfont 126,1,132,MAXROWS,DRFONT		# %

# header
# note: on pages after 1, only head2$ will have text
text 2,1.25,{rptdate$},HBFONT
text 1,1.25,{pageno$},HBRFONT,cols=MAXRCOLS
text 1,1.25,{head2$},HBCFONT,12,cols=MAXRCOLS
text 1,2.25,{head3$},HBCFONT,12,cols=MAXRCOLS
text 1,3.25,{head4$},HBCFONT,11,cols=MAXRCOLS
text 1,4.25,{head5$},HCFONT,11,cols=MAXRCOLS
text 1,5.25,{head6$},HCFONT,11,cols=MAXRCOLS
text 1,6.25,{head7$},HCFONT,11,cols=MAXRCOLS
text 1,7.25,{head8$},HCFONT,11,cols=MAXRCOLS

# detail heading
hline "==",erase
box "~^===",-.5,-2.5,132.5,2,1,DSHADE
font "~[0-9][0-9]/[0-9][0-9]",0,0,10,1,IRFONT
font "PERCENT",0,0,7,1,IRFONT

# detail
font "  Revenues",2,0,8,1,DBCFONT,11
font "  Cost of Sales",2,0,13,1,DBCFONT,11
font "  General & Admin",2,0,33,1,DBCFONT,11

# footer
erase "~^(Total)|(Gross Profit)|(Net Profit)",0,-1,MAXCOLS,1
bold "~^(Total)|(Gross Profit)|(Net Profit)",0,0,MAXCOLS,2
box "Total Revenues",-.5,-.6,132.5,1.1,1,DSHADE
box "Total Cost of Sal",-.5,-.6,132.5,1.1,1,DSHADE
box "Gross Profit",-.5,-.6,132.5,1.1,1,ISHADE
box "Total General & A",-.5,-.6,132.5,2.1,1,DSHADE
box "Net Profit or Los",-.5,-.6,132.5,1.1,1,HSHADE

[G/L Balance Sheet 850]
detect 0,1,"GLR850"

# document options
const MAXCOLS=80
const MAXRCOLS=79
const MAXROWS=66
const LEFTCOL=1
cols MAXCOLS
rows MAXROWS

prepage {
	head1$="",head2$="",head3$="",head4$=""
	head5$="",head6$="",head7$="",head8$=""

	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	head1$=trim(get(16,1,x-8-15))
	pageno=num(trim(get(x+4,1,3)))
	head2$=trim(get(1,2,MAXCOLS))
	if head2$(1,5)<>"AS OF" then \
		head3$=trim(get(1,3,MAXCOLS)); \
		head4$=trim(get(1,4,MAXCOLS)); \
		head5$=trim(get(1,5,MAXCOLS)); \
		head6$=trim(get(1,6,MAXCOLS)); \
		head7$=trim(get(1,7,MAXCOLS)); \
		head8$=trim(get(1,8,MAXCOLS))
	# handle different box sizes on heading
	if pageno=1 then xrow$="7.75" else xrow$="1.75"
	x$="cbox LEFTCOL,.5,MAXCOLS,"+xrow$+",MBOXSIZE,HSHADE"
	exec(x$)

	# erase headings
	if pageno=1 then end_row=9 else end_row=3
	for i=1 to end_row
		x$=set(1,i,MAXCOLS,"")
	next i
}

# default line enhancements
cfont 21,1,50,MAXROWS,DFONT				# desc
cfont 52,1,66,MAXROWS,DPFONT				# amt

# header
# note: on pages after 1, only head2$ will have text
text 2,1.25,{rptdate$},HBFONT
text 1,1.25,{pageno$},HBRFONT,cols=MAXRCOLS
text 1,1.25,{head2$},HBCFONT,12,cols=MAXRCOLS
text 1,2.25,{head3$},HBCFONT,12,cols=MAXRCOLS
text 1,3.25,{head4$},HBCFONT,11,cols=MAXRCOLS
text 1,4.25,{head5$},HCFONT,11,cols=MAXRCOLS
text 1,5.25,{head6$},HCFONT,11,cols=MAXRCOLS
text 1,6.25,{head7$},HCFONT,11,cols=MAXRCOLS
text 1,7.25,{head8$},HCFONT,11,cols=MAXRCOLS

# detail
font "  ASSETS",2,0,6,1,DBCFONT,11
font "  CURRENT ASSETS:",2,0,15,1,DBCFONT
font "  FIXED ASSETS:",2,0,13,1,DBCFONT
font "  Liabilities",2,0,20,1,DBCFONT,11
font "  Current Liabilities:",2,0,20,1,DBCFONT
font "  Long Term Liabilities:",2,0,22,1,DBCFONT
font "  Equity",2,0,6,1,DBCFONT,10

# footer
erase "Total",0,-1,MAXCOLS,1
bold "Total",0,0,MAXCOLS,1				# tot lines
box "Total",-1.5,-.5,46,1.01,1,DSHADE
box "Total Assets",-1.5,-.5,46,1.01,1,ISHADE
box "Total Liabilities & Equity",-1.5,-.5,46,1.01,1,ISHADE 

[G/L Balance Sheet 852]
detect 0,1,"GLR852"

# document options
const MAXCOLS=80
const MAXRCOLS=79
const MAXROWS=66
const LEFTCOL=1
cols MAXCOLS
rows MAXROWS

prepage {
	head1$="",head2$="",head3$="",head4$=""
	head5$="",head6$="",head7$="",head8$=""

	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	head1$=trim(get(16,1,x-8-15))
	pageno=num(trim(get(x+4,1,3)))
	head2$=trim(get(1,2,MAXCOLS))
	if head2$(1,5)<>"AS OF" then \
		head3$=trim(get(1,3,MAXCOLS)); \
		head4$=trim(get(1,4,MAXCOLS)); \
		head5$=trim(get(1,5,MAXCOLS)); \
		head6$=trim(get(1,6,MAXCOLS)); \
		head7$=trim(get(1,7,MAXCOLS)); \
		head8$=trim(get(1,8,MAXCOLS))
	# handle different box sizes on heading
	if pageno=1 then xrow$="7.75" else xrow$="1.75"
	x$="cbox LEFTCOL,.5,MAXCOLS,"+xrow$+",MBOXSIZE,HSHADE"
	exec(x$)

	# get years for detail heading
	if pageno=1 then xrow=9 else xrow=3
	year1$=trim(get(50,xrow,10)),year2$=trim(get(70,xrow,10))

	# erase headings
	if pageno=1 then end_row=9 else end_row=3
	for i=1 to end_row
		x$=set(1,i,MAXCOLS,"")
	next i
}

# default line enhancements
cfont 13,1,42,MAXROWS,DFONT				# desc
cfont 44,1,58,MAXROWS,DPFONT				# current amt
cfont 60,1,76,MAXROWS,DPFONT				# prev amt

# header
# note: on pages after 1, only head2$ will have text
text 2,1.25,{rptdate$},HBFONT
text 1,1.25,{pageno$},HBRFONT,cols=MAXRCOLS
text 1,1.25,{head2$},HBCFONT,12,cols=MAXRCOLS
text 1,2.25,{head3$},HBCFONT,12,cols=MAXRCOLS
text 1,3.25,{head4$},HBCFONT,11,cols=MAXRCOLS
text 1,4.25,{head5$},HCFONT,11,cols=MAXRCOLS
text 1,5.25,{head6$},HCFONT,11,cols=MAXRCOLS
text 1,6.25,{head7$},HCFONT,11,cols=MAXRCOLS
text 1,7.25,{head8$},HCFONT,11,cols=MAXRCOLS

# detail header
hline "==",erase
box "~^===",0,-1.5,79,1.1,1,DSHADE
text "~^===",44,-1,{year1$},IRFONT,cols=11
text "~^===",60,-1,{year2$},IRFONT,cols=13

# detail
font "  ASSETS",2,0,6,1,DBCFONT,11
font "  CURRENT ASSETS:",2,0,15,1,DBCFONT
font "  FIXED ASSETS:",2,0,13,1,DBCFONT
font "  Liabilities",2,0,20,1,DBCFONT,11
font "  Current Liabilities:",2,0,20,1,DBCFONT
font "  Long Term Liabilities:",2,0,22,1,DBCFONT
font "  Equity",2,0,6,1,DBCFONT,10

# footer
erase "Total",0,-1,MAXCOLS,1
bold "Total",0,0,MAXCOLS,1				# tot lines
box "Total",-1,-.5,63,1.01,1,DSHADE
box "Total Assets",-1,-.5,63,1.01,1,ISHADE
box "Total Liabilities & Equity",-1,-.5,63,1.01,1,ISHADE 

[G/L Balance Sheet 854]
detect 0,1,"GLR854"

# document options
const MAXCOLS=132
const MAXRCOLS=131
const MAXROWS=58
const LEFTCOL=.5
cols MAXCOLS
rows MAXROWS
landscape

prepage {
	head1$="",head2$="",head3$="",head4$=""
	head5$="",head6$="",head7$="",head8$=""

	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	head1$=trim(get(16,1,x-8-15))
	pageno=num(trim(get(x+4,1,3)))
	head2$=trim(get(1,2,MAXCOLS))
	head3$=trim(get(1,3,MAXCOLS))
	if head3$<>"" then \
		head4$=trim(get(1,4,MAXCOLS)); \
		head5$=trim(get(1,5,MAXCOLS)); \
		head6$=trim(get(1,6,MAXCOLS)); \
		head7$=trim(get(1,7,MAXCOLS)); \
		head8$=trim(get(1,8,MAXCOLS))
	# handle different box sizes on heading
	if pageno=1 then xrow$="7.75" else xrow$="1.75"
	x$="cbox LEFTCOL,.5,MAXCOLS,"+xrow$+",MBOXSIZE,HSHADE"
	exec(x$)

	# erase headings
	if pageno=1 then end_row=8 else end_row=3
	for i=1 to end_row
		x$=set(1,i,MAXCOLS,"")
	next i
}

# default line enhancements
cfont 13,1,21,MAXROWS,DPFONT			# 1st period
cfont 23,1,31,MAXROWS,DPFONT			# 2nd period
cfont 33,1,41,MAXROWS,DPFONT			# 3rd period
cfont 43,1,51,MAXROWS,DPFONT			# 4th period
cfont 53,1,61,MAXROWS,DPFONT			# 5th period
cfont 63,1,71,MAXROWS,DPFONT			# 6th period
cfont 73,1,81,MAXROWS,DPFONT			# 7th period
cfont 83,1,91,MAXROWS,DPFONT			# 8th period
cfont 93,1,101,MAXROWS,DPFONT			# 9th period
cfont 103,1,111,MAXROWS,DPFONT		# 10th period
cfont 113,1,121,MAXROWS,DPFONT		# 11th period
cfont 123,1,131,MAXROWS,DPFONT		# 12th period

# header
# note: on pages after 1, only head2$ will have text
text 2,1.25,{rptdate$},HBFONT
text 1,1.25,{pageno$},HBRFONT,cols=MAXRCOLS
text 1,1.25,{head2$},HBCFONT,12,cols=MAXRCOLS
text 1,2.25,{head3$},HBCFONT,12,cols=MAXRCOLS
text 1,3.25,{head4$},HBCFONT,11,cols=MAXRCOLS
text 1,4.25,{head5$},HCFONT,11,cols=MAXRCOLS
text 1,5.25,{head6$},HCFONT,11,cols=MAXRCOLS
text 1,6.25,{head7$},HCFONT,11,cols=MAXRCOLS
text 1,7.25,{head8$},HCFONT,11,cols=MAXRCOLS

# detail heading
hline "==",erase
box "~^===",-1.5,-1.8,131.5,1.4,1,DSHADE
const XMASK=[0-9][0-9]/[0-9][0-9]
font "~XMASK@1,4,MAXCOLS,10",0,0,9,1,IRFONT 	# dt

# detail
font "~^[A-Z0-9]@1,6",0,0,MAXCOLS,1,DBFONT	# acnt desc
font "  ASSETS",2,0,6,1,DBCFONT,11
font "  CURRENT ASSETS:",2,0,15,1,DBCFONT
font "  FIXED ASSETS:",2,0,13,1,DBCFONT
font "  Liabilities",2,0,20,1,DBCFONT,11
font "  Current Liabilities:",2,0,20,1,DBCFONT
font "  Long Term Liabilities:",2,0,22,1,DBCFONT
font "  Equity",2,0,6,1,DBCFONT,10

# footer
erase "~^Total",0,-1,MAXCOLS,1
bold "~^Total",0,0,MAXCOLS,2				# tot lines
box "~^Total",-1.5,-.8,MAXCOLS,2.4,1,DSHADE
box "~^Total Assets",-1.5,-.8,132,2.4,1,ISHADE
box "~^Total Liabilities & Equity",-1.5,-.8,132,2.4,1,ISHADE 

[G/L Balance Sheet 856]
detect 0,1,"GLR856"

# document options
const MAXCOLS=132
const MAXRCOLS=131
const MAXROWS=58
const LEFTCOL=.5
cols MAXCOLS
rows MAXROWS
landscape

prepage {
	head1$="",head2$="",head3$="",head4$=""
	head5$="",head6$="",head7$="",head8$=""

	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	head1$=trim(get(16,1,x-8-15))
	pageno=num(trim(get(x+4,1,3)))
	head2$=trim(get(1,2,MAXCOLS))
	head3$=trim(get(1,3,MAXCOLS))
	if head3$<>"" then \
		head4$=trim(get(1,4,MAXCOLS)); \
		head5$=trim(get(1,5,MAXCOLS)); \
		head6$=trim(get(1,6,MAXCOLS)); \
		head7$=trim(get(1,7,MAXCOLS)); \
		head8$=trim(get(1,8,MAXCOLS))
	# handle different box sizes on heading
	if pageno=1 then xrow$="7.75" else xrow$="1.75"
	x$="cbox LEFTCOL,.5,MAXCOLS,"+xrow$+",MBOXSIZE,HSHADE"
	exec(x$)

	# erase headings
	if pageno=1 then end_row=8 else end_row=2
	for i=1 to end_row
		x$=set(1,i,MAXCOLS,"")
	next i
}

# default line enhancements
cfont 1,1,30,MAXROWS,DFONT			# desc
cfont 32,1,46,MAXROWS,DPFONT			# 1nd period
cfont 48,1,63,MAXROWS,DPFONT			# 2rd period
cfont 65,1,80,MAXROWS,DPFONT			# 3th period
cfont 82,1,97,MAXROWS,DPFONT			# 4th period
cfont 99,1,114,MAXROWS,DPFONT			# 5th period
cfont 116,1,131,MAXROWS,DPFONT		# 6th period

# header
# note: on pages after 1, only head2$ will have text
text 2,1.25,{rptdate$},HBFONT
text 1,1.25,{pageno$},HBRFONT,cols=MAXRCOLS
text 1,1.25,{head2$},HBCFONT,12,cols=MAXRCOLS
text 1,2.25,{head3$},HBCFONT,12,cols=MAXRCOLS
text 1,3.25,{head4$},HBCFONT,11,cols=MAXRCOLS
text 1,4.25,{head5$},HCFONT,11,cols=MAXRCOLS
text 1,5.25,{head6$},HCFONT,11,cols=MAXRCOLS
text 1,6.25,{head7$},HCFONT,11,cols=MAXRCOLS
text 1,7.25,{head8$},HCFONT,11,cols=MAXRCOLS

# detail heading
hline "==",erase
box "~^===",-1.5,-1.7,131.5,1.2,1,DSHADE
const XMASK=[0-9][0-9]/[0-9][0-9]
font "~XMASK@1,4,MAXCOLS,10",0,0,9,1,IRFONT 	# dt

# detail
font "  ASSETS",2,0,6,1,DBCFONT,11
font "  CURRENT ASSETS:",2,0,15,1,DBCFONT
font "  FIXED ASSETS:",2,0,13,1,DBCFONT
font "  Liabilities",2,0,20,1,DBCFONT,11
font "  Current Liabilities:",2,0,20,1,DBCFONT
font "  Long Term Liabilities:",2,0,22,1,DBCFONT
font "  Equity",2,0,6,1,DBCFONT,10

# footer
erase "~^Total",0,-1,MAXCOLS,1
bold "~^Total",0,0,MAXCOLS,2				# tot lines
box "~^Total",-1.5,-.7,MAXCOLS,1.2,1,DSHADE
box "~^Total Assets",-1.5,-.7,132,1.2,1,ISHADE
box "~^Total Liabilities & Equity",-1.5,-.7,132,1.2,1,ISHADE 

[G/L Balance Sheet 880]
detect 0,1,"GLR880"

# document options
const MAXCOLS=80
const MAXRCOLS=79
const MAXROWS=66
const LEFTCOL=.5
cols MAXCOLS
rows MAXROWS

prepage {
	head1$="",head2$="",head3$="",head4$=""
	head5$="",head6$="",head7$="",head8$=""

	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	head1$=trim(get(16,1,x-8-15))
	pageno=num(trim(get(x+4,1,3)))
	head2$=trim(get(1,2,MAXCOLS))
	if head2$(1,5)<>"AS OF" then \
		head3$=trim(get(1,3,MAXCOLS)); \
		head4$=trim(get(1,4,MAXCOLS)); \
		head5$=trim(get(1,5,MAXCOLS)); \
		head6$=trim(get(1,6,MAXCOLS)); \
		head7$=trim(get(1,7,MAXCOLS)); \
		head8$=trim(get(1,8,MAXCOLS))
	# handle different box sizes on heading
	if pageno=1 then xrow$="7.75" else xrow$="1.75"
	x$="cbox LEFTCOL,.5,MAXCOLS,"+xrow$+",MBOXSIZE,HSHADE"
	exec(x$)

	# erase headings
	if pageno=1 then end_row=8 else end_row=2
	for i=1 to end_row
		x$=set(1,i,MAXCOLS,"")
	next i
}

# default line enhancements
cfont 1,1,4,MAXROWS,DCFONT				# line #
cfont 6,1,6,MAXROWS,DCFONT				# T
cfont 8,1,37,MAXROWS,DFONT				# desc
cfont 39,1,52,MAXROWS,DFONT				# g/l #
cfont 54,1,MAXCOLS,MAXROWS,DSFONT			# acnt desc

# header
# note: on pages after 1, only head2$ will have text
text 2,1.25,{rptdate$},HBFONT
text 1,1.25,{pageno$},HBRFONT,cols=MAXRCOLS
text 1,1.25,{head2$},HBCFONT,12,cols=MAXRCOLS
text 1,2.25,{head3$},HBCFONT,12,cols=MAXRCOLS
text 1,3.25,{head4$},HBCFONT,11,cols=MAXRCOLS
text 1,4.25,{head5$},HCFONT,11,cols=MAXRCOLS
text 1,5.25,{head6$},HCFONT,11,cols=MAXRCOLS
text 1,6.25,{head7$},HCFONT,11,cols=MAXRCOLS
text 1,7.25,{head8$},HCFONT,11,cols=MAXRCOLS

# detail heading
hline "==",erase
box "~^===",-1.25,-1.5,79.5,1.1,1,DSHADE
font "~^LINE T",0,0,4,1,ICFONT			# line #
font "~^LINE T",5,0,1,1,ICFONT			# T
font "~^LINE T",7,0,30,1,IFONT			# desc
font "~^LINE T",38,0,14,1,IFONT			# g/l #
font "~^LINE T",53,0,27,1,IFONT			# acnt desc

# detail
hline "---",erase
font "~^UNUSED",0,0,36,1,DFONT

# footer
font "~^TOTAL UNUSED",0,0,32,1,DFONT		# unused total title
font "~^TOTAL UNUSED",39,0,3,1,DBFONT		# # unused

[G/L Chart of Accounts]
detect 0,2,"CHART OF ACCOUNTS"

# document options
const MAXCOLS=81
const MAXRCOLS=80
const MAXROWS=66
const LEFTCOL=.5
cols MAXCOLS
rows MAXROWS

pcopies 1

prepage {
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	compname$=trim(get(16,1,x-8-16))
	pageno=num(pageno$(13))

	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	time$=trim(get(x,2,15))
	title$=trim(get(16,2,x-16))

	# load sub-title
	subtitle$=""
	if pageno=1 then subtitle$=trim(get(1,4,MAXCOLS))

	# erase headers
	if pageno=1 then end_row=4 else end_row=2
	for i=1 to end_row
		x$=set(1,i,MAXCOLS,"")
	next i

	# handle header box
	if pageno=1 then xrow$="3.75" else xrow$="2.75"
	x$="cbox LEFTCOL,.5,MAXCOLS,"+xrow$+",MBOXSIZE,HSHADE"
	exec(x$)
}

# default line enhancements
cfont 1,1,14,MAXROWS,DBFONT
cfont 16,1,45,MAXROWS,DFONT
cfont 47,1,68,MAXROWS,DBFONT
cfont 70,1,MAXCOLS,MAXROWS,DBFONT

# header
text 2,1.25,{rptdate$},HBFONT
text 1,1.25,{compname$},HBCFONT,14,cols=MAXRCOLS
text 1,1.25,{pageno$},HBRFONT,cols=MAXRCOLS

text 2,2.25,{user$},HBFONT
text 1,2.25,{title$},HBCFONT,12,cols=MAXRCOLS
text 1,2.25,{time$},HBRFONT,cols=MAXRCOLS

text 1,3.25,{subtitle$},HCFONT,12,cols=MAXRCOLS

# detail heading
cfont 1,5,8,6,IFONT
cfont 16,5,26,6,IFONT
cfont 47,4,53,6,IFONT
cfont 70,4,78,6,IFONT
hline "=="

# footer
font "ACCOUNTS:",0,0,20,1,IBFONT
font "END OF REPORT",0,0,13,1,IBFONT

[G/L Trial Balance]
detect 0,2,"TRIAL BALANCE"
detect 0,0,"BEGINNING        ACTIVITY         ENDING"

# document options
const MAXCOLS=81
const MAXRCOLS=80
const MAXROWS=66
const LEFTCOL=.5
cols MAXCOLS
rows MAXROWS

prepage {
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	compname$=trim(get(16,1,x-8-16))

	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	time$=trim(get(x,2,15))
	title$=trim(get(16,2,x-16))

	# load row 4 variables
	period_date$=trim(get(1,4,MAXCOLS))
}

# default line enhancements
cfont "G/L#   @1,5,7,11",0,2,14,MAXROWS,DBFONT		# g/l #
cfont "G/L#   @1,5,7,11",15,2,35,MAXROWS,DFONT		# desc
font "~\.[0-9][0-9]@1,8",-8,0,12,1,DBPFONT		# amts

# header
cerase 1,1,MAXCOLS,4
cbox LEFTCOL,.5,MAXCOLS,3.75,3,HSHADE
text 2,1.25,{rptdate$},HBFONT
text 1,1.25,{compname$},HBCFONT,14,cols=MAXCOLS
text 1,1.25,{pageno$},HBRFONT,cols=MAXRCOLS
text 2,2.25,{user$},HBFONT
text 1,2.25,{title$},HBCFONT,12,cols=MAXCOLS
text 1,2.25,{time$},HBRFONT,cols=MAXRCOLS
text 1,3.25,{period_date$},HBCFONT,cols=MAXCOLS

# subheader
font "~G/L# [A-Z0-9]@1,6,7,6",0,0,MAXCOLS,1,IFONT	# opts

# detail heading
erase "G/L#   @1,5,7,11",0,1,MAXCOLS,1
box "G/L#   @1,5,7,11",-.5,-1,80.5,2,1,DSHADE
font "G/L#   @1,5,7,11",0,0,4,1,IFONT			# g/l #
font "G/L#   @1,5,7,11",15,0,11,1,IFONT			# desc
font "G/L#   @1,5,7,11",39,0,9,1,ICFONT			# begin
font "G/L#   @1,5,7,11",56,0,8,1,ICFONT			# act
font "G/L#   @1,5,7,11",73,0,6,1,IFONT			# ending

# footer
erase "TOTAL@61,5,66,MAXROWS",0,-1,MAXCOLS,1
box "TOTAL@61,5,65,MAXROWS",7,-1,12,1
box "TOTAL@62,5,66,MAXROWS",6,-1,12,1
font "TOTAL@61,5,65,MAXROWS",-50,0,56,1,IBCFONT,10
font "TOTAL@62,5,66,MAXROWS",-50,0,55,1,IBCFONT,10
font "TOTAL@61,5,65,MAXROWS",7,0,12,1,DBPFONT,10
font "TOTAL@62,5,66,MAXROWS",6,0,12,1,DBPFONT,10
font "TOTAL@61,5,65,MAXROWS",19,0,1,1,DBPFONT,10
font "TOTAL@62,5,66,MAXROWS",18,0,1,1,DBPFONT,10

# footer
font "ACCOUNTS:",0,0,20,1,IBFONT
font "END OF REPORT",0,0,13,1,IBFONT

[P/O Fill Report]
detect 0,2,"PURCHASE ORDER FILL REPORT"

# document options
const MAXCOLS=133
const MAXRCOLS=132
const LEFTCOL=.5
const MAXROWS=62
cols MAXCOLS
rows MAXROWS
landscape

prepage {
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	pageno$=trim(get(x-7,1,15))
	compname$=trim(get(16,1,x-8-16))
	pageno=num(pageno$(13))

	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	time$=trim(get(x,2,15))
	title$=trim(get(16,2,x-16))
}

# default enhancement line
cfont 1,1,20,MAXROWS,DSBRFONT				# item #
cfont 22,1,52,MAXROWS,DSFONT				# desc
cfont 54,1,61,MAXROWS,DSBRFONT			# rcvd
cfont 63,1,64,MAXROWS,DSBCFONT			# um
cfont 66,1,71,MAXROWS,DSBRFONT			# order #
cfont 73,1,75,MAXROWS,DSBFONT				# ln #
cfont 77,1,83,MAXROWS,DSBCFONT			# bin loc
cfont 85,1,92,MAXROWS,DSBCFONT			# req date
cfont 94,1,118,MAXROWS,DSFONT				# customer
cfont 120,1,129,MAXROWS,DSBRFONT			# B/O + comm
cfont 131,1,132,MAXROWS,DSBCFONT			# um

# header
cerase 1,1,MAXCOLS,3
cbox LEFTCOL,.5,MAXCOLS,3.25,MBOXSIZE,HSHADE
text 2,1.25,{rptdate$},HBFONT
text 1,1.25,{compname$},HBCFONT,14,cols=MAXCOLS
text 1,1.25,{pageno$},HBRFONT,cols=MAXRCOLS
text 2,2.75,{user$},HBFONT
text 1,2.75,{title$},HBCFONT,12,cols=MAXCOLS
text 1,2.75,{time$},HBRFONT,cols=MAXRCOLS

# subheader
cfont "~^[A-Z]@1,4,1,5",0,0,MAXCOLS,1,IFONT

# detail heading
cfont 1,4,20,7,IRFONT,7					# item #
cfont 22,4,52,7,IFONT,7					# desc
cfont 54,4,61,7,IRFONT,7				# rcvd
cfont 63,4,64,7,ICFONT,7				# um
cfont 66,4,71,7,IRFONT,7				# order #
cfont 73,4,75,7,IFONT,7					# ln #
cfont 81,4,83,7,IFONT,7					# bin loc
cfont 85,4,92,7,ICFONT,7				# req date
cfont 94,4,118,7,IFONT,7				# customer
cfont 119,4,129,7,IRFONT,7,black			# B/O + comm
cfont 131,4,132,7,ICFONT,7				# um
hline "=="

# PO# line
font "PO#:@1,7,MAXCOLS,MAXROWS",0,0,4,1,DFONT		# po title
font "PO#:@1,7,MAXCOLS,MAXROWS",5,0,7,1,DBFONT		# po #
font "Vendor:@1,7,MAXCOLS,MAXROWS",0,0,7,1,DRFONT	# vndr title
font "Vendor:@1,7,MAXCOLS,MAXROWS",8,0,42,1,DBFONT	# vndr
font "Whse:@1,7,MAXCOLS<MAXROWS",0,0,5,1,DFONT		# whse title
font "Whse:@1,7,MAXCOLS,MAXROWS",6,0,10,1,DBFONT	# whse

# alt loc line
font "Alt Loc: ",0,0,8,1,DFONT
font "Alt Loc: ",9,0,50,1,DSBFONT

# footer
font "ITEMS:",0,-2,MAXCOLS,1,IBFONT
font "ITEMS:",0,0,20,1,IBFONT
font "End of Report",0,0,13,1,IBFONT

#***************************************************************
#              Inactive or testing rule sets                   *
#***************************************************************



################################################################
# Generic ######################################################
################################################################

[Generic]
# This rule set will set columns & rows and 
# enhance the hdg for all other reports
# requires UnForm 4.1.05, rem out detect below if not this 
# version or higher
detect 0,1,"~(PAGE)|(Page)"

# document options
const MAXROWS=66
cols 150		# temp value until setup in prepage
rows MAXROWS

prepage {
	maxlen=80				# minimum # of columns is 80
	for i=1 to MAXROWS
		if len(cvs(text$[i],2))>maxlen then \
			maxlen=len(cvs(text$[i],2))
	next i
	cols$=str(maxlen+1)
	# load row 1 variables
	rptdate$=trim(get(1,1,15))
	x=pos("PAGE"=text$[1])
	if x=0 then x=pos("Page"=text$[1])
	pageno$=trim(get(x-7,1,15))
	compname$=trim(get(16,1,x-8-16))
	x$=set(1,1,200,"")
	# load row 2 variables
	user$=trim(get(1,2,15))
	x=pos("TIME"=text$[2])
	if x=0 then x=pos("Time"=text$[2])
	if x>0 then time$=trim(get(x,2,15))
	title$=trim(get(16,2,x-16))
	x$=set(1,2,200,"")

	# Now draw box around header
	exec("cbox 1,.5,"+cols$+",2.75,MBOXSIZE,HSHADE")
	# now place line 1 headers that need justification
	x$="text 1,1.25,"+$22$+compname$+$22$+ \
		",HBCFONT,14,cols="+str(maxlen)
	exec(x$)
	x$="text 1,1.25,"+$22$+pageno$+$22$+ \
		",HBRFONT,cols="+str(maxlen)
	exec(x$)
	# now place line 2 headers that need justification
	x$="text 1,2.25,"+$22$+title$+$22$+ \
		",HBCFONT,12,cols="+str(maxlen)
	exec(x$)
	x$="text 1,2.25,"+$22$+time$+$22$+ \
		",HBRFONT,cols="+str(maxlen)
	exec(x$)
}

text 2,1.25,{rptdate$},HBFONT
text 2,2.25,{user$},HBFONT
font "~(End of Report)|(END OF REPORT)",0,0,13,1,IBFONT

# Old Modification History ###################################
# 06/15/2001 - bcj
# 	added new rule sets - G/L balance sheet & profit & loss
# 09/18/2001 - bcj
# 	added memo line enhancing to I/C transfer ticket, purchase
#	orders S/O counter sales, S/O invoices, S/O pick tickets,
#	S/O quotes
# 	added ability to handle prepayments to S/O counter sales 
#	and invoices
# 	added RGA's to S/O invoice short form
# 11/02/2001 - bcj
#	increased area to load ship to's, bill to's, 
#	and vendor codes.
# 11/30/2001 - bcj
#	added routing # to ap & pr checks
#	adjusted format of ap & pr checks to match
# 12/17/2001 - bcj
#	tested with version 5.0
# 	fixed problem with memo lines in transfer ticket
# 12/28/2001 - bcj
#	fixed generic rule set problem
# 02/21/2002 - bcj
#	increased size of payment comments enhancements in long 
#	and short invoice
# 02/22/2002 - bcj
#	fixed problem with "End of Report" printing off page by
#	adjusting font from 9 to 8
# 03/5/2002 - bcj
#	Increased consistency of fonts between forms and reports
#	by moving constants to top of rule file
# 03/15/2002 - bcj
#	changed company constants for more informative information
# 03/19/2002 - bcj
#	added email address and web site to all forms
# 03/22/2002 - bcj
#	added serial # handling for all S/O invoice forms
# 	added rule set for G/L Chart of Accounts
# 03/25/2002 - bcj
#	tested all S/O forms with alignment forms, adjusted accordingly
#	same for P/O forms and I/C transfer ticket, A/R dunning letter
# 03/26/2002 - bcj
#	same for all A/R invoices and statements.
#	added rule set for P/O Fill report
# 	fixed problem with Aged Trial Balance with transactions not
#	recognizing & enhancing transactions on line by itself
#	added rule set for A/P Cash Requirements Report
#	adjusted detects on G/L balance sheet and income statement to
#	only handle GLR854 and GLR840
# 03/29/2002 - BCJ
#	removed minimized fonting from all pertinent reports, not from
#	forms. If minimized fonting is "needed", just put a # in front
#	of detects of pertinent reports and they will pass thru to the
#	generic report enhancer which only enhances main heading
# 03/29/2002 - bcj
#	major change to reports by moving "normal" detail line enhancing
#	to the top of the rule set means no need to determine type of
#	line. All exceptions handled afterwards
# 03/29/2002 - bcj
#	added rule set for M/C Production Ticket
# 04/02/2002 - bcj
#	added rule sets for A/P vouchers, glr820, glr880
# 04/02/2002 - bcj
#	added multi-page capability to I/C transfer ticket and fixed
#	problem of no enhancements on last detail line: item # and desc
# 04/03/2002 - bcj
#	added rule sets to handle glr822, glr824, glr826, glr828
#	added rule sets to handle glr838, glr850, glr852, glr856
# 04/04/2002 - bcj
#	added rule sets to handle glr834, glr836, glr842, glr848
# 04/05/2002 - bcj
#	added rule set to handle glr844
# 04/08/2002 - bcj
#	added rule set to handle long stub P/R check
# 04/09/2002 - bcj
# 	moved reports to the bottom leaving forms as is to improve 
#	speed up execution for forms. Notice that the modular effect is
#	kept as the organization is duplicated
# 04/26/2002 - bcj
#	Corrected problem with missing quotes around COMP_LOGO causing
#	non-lower-case image file names to be not found