compile function CUST_ACTIVITY_RPT1() 
begin condition
pre:
post:
end condition
declare function msg, set_property, send_event, dialog_box, utility, get_property
declare function set_printer, fieldcount, key_sort, ex_vm_rem, Printer_Select
declare subroutine rlist, or_view, activate_save_select, yield, extract_si_keys
declare subroutine update_index, btree.extract
$insert logical
$insert rlist_equates
$insert msg_equates
$insert names_equates
$insert quote_equ
$insert quote_spec_equ
$insert invoice_equ
$insert order_equ
$insert company_equ
$insert annual_contracts_equ
$insert oiprint_equates
$insert prod_spec_equ

Params = dialog_box( 'CUST_ACTIVITY_RPT1', @window, '*CENTER' )
if Params = 'CANCEL' or Params = '' then
   return 0
end
Stat = utility( 'CURSOR', 'H' )
convert '*' to @fm in Params
CustNo       = Params<1>
Time         = Params<2> ;* prev mo, prev qtr, prev year if this param has a value then
                         ;* ignore param 3 and 4
StartDate    = Params<3> ;* they specified a certain date range start
EndDate      = Params<4> ;*  "       "     "    "     "     "    end
OrderStat    = Params<5> ;* open, closed or all orders
QuoteStat    = Params<6> ;* orders only or all quotes
DirToPrinter = Params<7>
PrintSpecOnly= Params<8>
Today        = date()
TodayOut     = oconv( Today, 'D4/' )
if Time <> '' then
   * set StartDate and EndDate to actual dates if a Time was choosen
   Months      = '1/2/3/4/5/6/7/8/9/10/11/12'
   DaysInMonth = '31/28/31/30/31/30/31/31/30/31/30/31'
   convert '/' to @fm in Months
   convert '/' to @fm in DaysInMonth
   * setup quarters
   CurYear = field(TodayOut,'/',3)
   Q1S = iconv( '1/1/':CurYear,   'D' )
   Q1E = iconv( '3/31/':CurYear,  'D' )
   Q2S = iconv( '4/1/':CurYear,   'D' )
   Q2E = iconv( '6/30/':CurYear,  'D' )
   Q3S = iconv( '7/1/':CurYear,   'D' )
   Q3E = iconv( '9/30/':CurYear,  'D' )
   Q4S = iconv( '10/1/':CurYear,  'D' )
   Q4E = iconv( '12/31/':CurYear, 'D' )
   begin case
    case Time = 'Previous Month'
       PrevMonth = ((field(TodayOut,'/',1)+0)-1)
       YrToUse   = field(TodayOut,'/',3)
       if PrevMonth = 0 then
          * in other words it is january so the previous would be december
          * so also need to set to previous year
          PrevMonth = 12
          YrToUse -=1
       end
       StartDate = PrevMonth:'/1/':YrToUse
       if PrevMonth = 2 then
          * see if it is leap year
          if len(iconv(PrevMonth:'/29/':YrToUse, 'D')) then
             EndDate = PrevMonth:'/29/':YrToUse
          end else
             EndDate = PrevMonth:'/28/':YrToUse
          end
       end else
          MonthDays = DaysInMonth<PrevMonth>
          EndDate   = PrevMonth:'/':MonthDays:'/':YrToUse
       end
    case Time = 'Previous Qtr'
       * what quarter are we in
       begin case
          case Today >= Q1S and Today <= Q1E
             * use previous year quarter
             StartDate = '10/1/':CurYear-1
             EndDate   = '12/31/':CurYear-1
          case Today >= Q2S and Today <= Q2E
             StartDate = oconv( Q1S, 'D2/' )
             EndDate   = oconv( Q1E, 'D2/' ) 
          case Today >= Q3S and Today <= Q3E
             StartDate = oconv( Q2S, 'D2/' )
             EndDate   = oconv( Q2E, 'D2/' ) 
          case Today >= Q4S and Today <= Q4E
             StartDate = oconv( Q3S, 'D2/' )
             EndDate   = oconv( Q3E, 'D2/' )
       end case 
    case Time = 'Previous Year'
       PrevYear  = (field(TodayOut,'/',3)-1)
       StartDate = '1/1/':PrevYear
       EndDate   = '12/31/':PrevYear        
  end case
end
gosub PrinterInit
Font<2> = 12
Void = set_printer( 'FONT', Font )
***************** program logic flow ********************************
*1) print customer information
*2) retrieve all annual contracts and print info if none don't print
*3) retrieve all quotes and loop through
*4) with each quote find orders used in that time frame and print info
*5) if order open print balance information
*********************************************************************
*(1) STEP ONE
CustRec = xlate( 'COMPANY', CustNo, '', 'X' )
Lout = 'Customer Information for ':CustRec<company_co_name$>
Table = ''
Table<-1> = Lout
TableColInfo = '^+10973'
x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)
Table = 'Bill to Information':@vm:'Ship to Information'
TableColInfo = '^+5486':@vm:'^+5486'
x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)
Table = ''
BTAddr = CustRec<company_bill_to_address$>
swap @vm with '  ' in BTAddr
STAddr = CustRec<company_ship_to_address$>
swap @vm with '  ' in STAddr
Table<-1> = 'Attn:':@vm:CustRec<company_bill_to_attn$>:@vm:'Attn:':@vm:CustRec<company_ship_to_attn$>
Table<-1> = 'Company:':@vm:CustRec<company_bill_to_co$>:@vm:'Company:':@vm:CustRec<company_ship_to_co$>
Table<-1> = 'Address:':@vm:BTAddr:@vm:'Address:':@vm:STAddr
Table<-1> = 'City:':@vm:CustRec<company_bill_to_city$>:@vm:'City:':@vm:CustRec<company_ship_to_city$>
Table<-1> = 'State:':@vm:CustRec<company_bill_to_state$>:@vm:'State:':@vm:CustRec<company_ship_to_state$>
Table<-1> = 'Zip:':@vm:CustRec<company_bill_to_zip$>:@vm:'Zip:':@vm:CustRec<company_ship_to_zip$>
TableColInfo = '<+1440':@vm:'<+4046':@vm:'<+1440':@vm:'<+4046'
x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)
Void = set_printer( 'TEXT', '' )
*(2) STEP TWO
open 'DICT.ANNUAL_CONTRACTS' to DictAnnConTable else
   MsgInfo = ''
   MsgInfo<mcol$> = -2
   MsgInfo<mrow$> = -2
   MsgInfo<mtext$> = 'Unable to open DICT.ANNUAL_CONTRACTS...'
   void = msg( '', MsgInfo )
   return 0
end  
SearchStr = ''
SearchStr<-1> = 'CUST_NO':@vm:CustNo
SearchStr<-1> = 'STATUS':@vm:'O' ;* force to open talk to Ray Krummen
SearchStr:= @fm
Flag = ''
btree.extract( SearchStr, 'ANNUAL_CONTRACTS', DictAnnConTable, ACKeys, '', Flag )
if Flag <> 0 then
   MsgInfo = ''
   MsgInfo<mcol$> = -2
   MsgInfo<mrow$> = -2
   MsgInfo<mtext$> = 'Error while extracting ANNUAL CONTRACT records...' 
   Void = msg( '', MsgInfo )
   return 0
end
if ACKeys then
   convert @vm to @fm in ACKeys
   ACKeys = key_sort( ACKeys, 'ANNUAL_CONTRACTS', 'ENTRY_DATE', 1 )
   * open annual contracts report on them
   ACCnt = fieldcount( ACKeys, @fm )
   for i = 1 to ACCnt
      ThisACRec = xlate( 'ANNUAL_CONTRACTS', ACKeys<i>, '', 'X' )
      Table = ''
      Lout = 'B L A N K E T':fmt('','L#3'):'O R D E R # ':ACKeys<i>
      Table<-1> = Lout
      TableColInfo = '<+10080'
		x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)      
      Table = ''
      Lout = ''
      *Void = set_printer( 'TEXT', 'Contract Date from ':oconv(ThisACRec<annual_contracts_from_date$>, 'D2/' ):' to ':oconv(ThisACRec<annual_contracts_thru_date$>, 'D2/' ))
      Table = ''
      Table<-1> = 'Contract Start ':oconv(ThisACRec<annual_contracts_from_date$>,'D2/'):@vm:'Contract End ':oconv(ThisACRec<annual_contracts_thru_date$>,'D2/')
      Table<-1> = 'Cust PO# ':ThisACRec<annual_contracts_po$>:@vm:'Quote# ':ThisACRec<annual_contracts_quote_num$>
      Table<-1> = 'Orig$ ':oconv( ThisACRec<annual_contracts_contract_amount$>, 'MD2,$' ):@vm:'Balance ':oconv( xlate( 'ANNUAL_CONTRACTS', ACKeys<i>, 'BALANCE', 'X' ), 'MD2,$' )
      TableColInfo = '<+5040':@vm:'<+5040'
		x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)
		Table = ''
		if ThisACRec<annual_contracts_notes$> <> '' then
		   TNote = ThisACRec<annual_contracts_notes$>
			convert @tm to ' ' in TNote
			TNote = trim(TNote)
		   Table = 'Description: ':TNote
         TableColInfo = '<+10080'		   
   		x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_BOX)		   
		end
   next i
   Void = set_printer('TEXT', '')     
end
*(3) STEP THREE
QuoteKeys = xlate( 'COMPANY', CustNo, 'QUOTE_KEYS', 'X' )
convert @vm to @fm in QuoteKeys
QuoteKeys = key_sort( QuoteKeys, 'QUOTE', 'ENTRY_DATE', 1 )
QKcnt = fieldcount( QuoteKeys, @fm )
open 'DICT.ORDER' to DictOrderTable else
   MsgInfo = ''
   MsgInfo<mtext$> = 'Unable to open DICT.ORDER...'
   MsgInfo<mcol$> = -2
   MsgInfo<mrow$> = -2
   void = msg( '', MsgInfo )
   return 0
end
OrdSearchAdd = ''
if OrderStat = 'Open Orders' then
   OrdSearchAdd = 'STATUS':@vm:'O'
end else
   if OrderStat = 'Closed Orders' then
      OrdSearchAdd = 'STATUS':@vm:'C' 
   end
   * if not then it is set to all so no need for OrdSearchAdd
end   
for i = 1 to QKcnt
   ThisQuote = QuoteKeys<i>
   QuoteRec = xlate( 'QUOTE', ThisQuote, '', 'X' )
   if PrintSpecOnly then
      gosub PrintQuoteSpec
   end else
      * show the order detail
	   SearchStr = ''
	   SearchStr<-1> = 'QUOTE_IDS':@vm:ThisQuote
	   SearchStr<-1> = 'ENTRY_DATE':@vm:StartDate:'...':EndDate
	   if OrdSearchAdd then
	      SearchStr<-1> = OrdSearchAdd
	   end
	   * EXPLAIN TO RAY THAT WHEN CHOOSING QUOTED PRODUCTS IT WILL SHOW QUOTES THAT WERE NOT 
	   * ORDERED IN THAT TIME FRAME BUT MAY HAVE BEEN ORDERED IN SOME OTHER TIME FRAME
	   SearchStr := @fm
	   btree.extract( SearchStr, 'ORDER', DictOrderTable, OrderKeys, '', Flag )
	   if Flag <> 0 then
          MsgInfo = ''
          MsgInfo<mtext$> = 'Error while extracting ORDER records...'
          MsgInfo<mcol$> = -2
          MsgInfo<mrow$> = -2
	      Void = msg( '', MsgInfo )
	      return 0
	   end
	   if OrderKeys then
	      if QuoteStat = 'Ordered Products' then
		      * orders placed with this quote
		      gosub PrintQuoteSpec
		      convert @vm to @fm in OrderKeys
		      OrderKeys = key_sort( OrderKeys, 'ORDER', 'ENTRY_DATE', 1 )
		      OKCnt = fieldcount( OrderKeys, @fm )
		      for j = 1 to OKCnt
		         ThisOrder = OrderKeys<j>
	            OrderRec = xlate( 'ORDER', ThisOrder, '', 'X' )
		         * NEED TO LOOP THROUGH QUOTE_IDS AND GET ONLY THE CORRECT ONES
		         * AND ADD UP QTY PRICE AND SRP
		         * quote order vars
		         OrderStatus = OrderRec<order_status$>
		         PO          = OrderRec<order_po$>
		         oQty        = 0
		         oPrice      = ''
		         oSRP        = 0
		         oTot        = 0
		         oSetup      = 0
		         WO          = ''
		         PartNum     = ''
		         * total order vars
		         OrderDate   = oconv(OrderRec<order_entry_date$>, 'D2/')
		         TotOrdAmt   = xlate( 'ORDER', OrderKeys<j>, 'TOTAL_AMOUNT', 'X' )
		         InvAmt      = 0
		         BalInvAmt   = 0
		         NonInvAmt   = 0
		         InvNos      = ''
		         * end total order vars
		         * FOR WORK ORDER AND PART NUMBER WILL REPORT ON THE FIRST LINE ITEM THAT
		         * USED THAT QUOTE
		         QIdCnt = fieldcount( OrderRec<order_quote_ids$>, @vm )
		         for k = 1 to QIdCnt
		            if OrderRec<order_quote_ids$,k> = ThisQuote then
		               * this line item is using the current quote so add up qty, price, srp
		               if WO = '' then
		                  WO = OrderRec<order_wo$,k>
		               end
		               if PartNum = '' then
		                  PartNum = OrderRec<order_part_num$,k>
		               end
		               oQty   += OrderRec<order_quantity$,k>
		               TPrice = OrderRec<order_price$,k>
		               if oPrice = '' then
		                  oPrice = TPrice ;* should always be the same price per wafer for same spec
		                                  ;* if not we have some major concerns at Epitronics Silicon Division
		               end
		               oSRP   += OrderRec<order_srp_charge$,k>
		               oSetup += OrderRec<order_setup_charge$,k>
		            end
		         next k
		         * NEED TO SHOW INVOICING INFO 
		         * NEED TO EXPLAIN THAT ORDER IS CLOSED WHEN PRODUCT IS SHIPPED
		         * BUT INVOICE STAYS OPEN UNTIL PAID
		         * NEED TO EXPLAIN TO RAY THAT THERE IS NO WAY OF TELLING ON A PARTIAL PAYMENT 
		         * OF A MULTIPLE QUOTE(PRODUCT) INVOICE WHICH PART IT WAS APPLIED TO.
		         * SO I AM SIMPLY GOING TO SHOW THE TOTAL INVOICED AMOUNT FOR THIS ORDER
		         * BALANCE OF THE INVOICED AMOUNT AND THE DIFFERECE IS THE NON INVOICED AMOUNT
		         * MEANING THE PRODUCT HAS NOT RUN...USE THE PO TO GO AGAINST INVOICES
	   		   extract_si_keys( 'INVOICE', 'PO',  PO, TInvIds )
	  		      tIcnt = fieldcount( TInvIds, @vm )
	  		      if tIcnt then
	  		         * we have invoices so show balance information
	               InvNos = TInvIds
	               swap @vm with '; ' in InvNos
	               InvAmt    = sum(xlate( 'INVOICE', TInvIds, 'INVOICE_AMOUNT', 'X' ))
	               BalInvAmt = sum(xlate( 'INVOICE', TInvIds, 'BALANCE', 'X' ))
	               NonInvAmt = (TotOrdAmt-InvAmt)
	  		      end else
	  		         * no invoices created so the balance is the original order amt
	  		         BalInvAmt = TotOrdAmt
	  		         NonInvAmt = TotOrdAmt 
	  		      end
	  		      * print total order info
	  		      Lout = 'TOTAL ORDER INFO FOR ORDER# ':ThisOrder 
	  		      Table = ''
	  		      Table<-1> = Lout
	  		      TableColInfo = '<+11073'
	            x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)  		      
	  		      Table = ''
	  		      Lout  = ''
	  		      Table<-1> = 'Date':@vm:'Order Amt':@vm:'Invoice Amt':@vm:'Non Invoice Amt':@vm:'Balance':@vm:'Invoice Nos'
	  		      Lout = OrderDate:@vm
	  		      Lout:= oconv(TotOrdAmt,'MD2,$'):@vm
	  		      Lout:= oconv(InvAmt,'MD2,$'):@vm
	  		      Lout:= oconv(NonInvAmt,'MD2,$'):@vm
	  		      Lout:= oconv(BalInvAmt,'MD2,$'):@vm
	  		      Lout:= InvNos
	  		      Table<-1> = Lout
	  		      TableColInfo = '<+1080':@vm:'<+1800':@vm:'<+1800':@vm:'<+1987':@vm:'<+1800':@vm:'<+2606'
	            x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)
	  		      Lout = 'ORDER INFO FOR QUOTE# ':ThisQuote
	  		      Table = ''
	  		      Table<-1> = Lout
	  		      TableColInfo = '<+11073'
	            x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)  		        		       
	  		      Table = ''
	  		      Lout  = ''
	  		      Table<-1> = 'PO#':@vm:'WO#':@vm:'Part Num':@vm:'Qty':@vm:'Price':@vm:'SRP':@vm:'Setup':@vm:'Total'
	  		      Lout = PO:@vm
	  		      Lout:= WO:@vm
	  		      Lout:= PartNum:@vm
	  		      Lout:= oQty:@vm
	  		      Lout:= oconv(oPrice,'MD2,$'):@vm
	  		      Lout:= oconv(oSRP,'MD2,$'):@vm
	  		      Lout:= oconv(oSetup,'MD2,$'):@vm
	  		      Lout:= oconv( ((oQty*oPrice)+oSRP+oSetup), 'MD2,$' )
	  		      Table<-1> = Lout
	  		      TableColInfo = '<+1714':@vm:'<+1440':@vm:'<+1440':@vm:'<+907':@vm:'<+1267':@vm:'<+1267':@vm:'<+1267':@vm:'<+1771'
	            x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)
	            Void = set_printer( 'TEXT', '' )  		                     		        
		      next j
		   end else
		      * the user choose 'Quoted Products' and we have orders so skip
		      * this Quote 
		      ******************* SKIP THE QUOTE ***************************
		   end
	   end else
	      * no orders against this Quote check to see if the user choose Quoted Products
	      if QuoteStat = 'Quoted Products' then
	         gosub PrintQuoteSpec
	      end
	      * only print the quote and specification there are no orders against this quote
	      * so no need to print anything 
	   end
	end
next i ;* looping through quotes 
Void = set_printer( 'TERM', 1 ) 
Stat = utility( 'CURSOR', 'A' )
return 0
*================================================================================================*
PrinterInit:
   * initialize the printer and set the headings
   if DirToPrinter = 'Yes' then
      OutputParam = 0
   end else
      OutputParam = 3 ;* maximized print preview
   end
   
   PrintPath = Printer_Select('',1)		;* Get default printer path
   Void = set_printer( 'INIT', '', '', '', '', OutputParam.PrintPath )
   
	TheHeader = "C U S T O M E R":fmt('','L#3'):"A C T I V I T Y":fmt('','L#3'):"R E P O R T":fmt('','L#10'):"(":StartDate:" - ":EndDate:")":fmt('','L#10'):" Page #'P'"
	Font = 'Times New Roman,14,L,1'	;* 14 point, Left just, Bold
   convert ',' to @fm in font		;* Use @FM delimiter
	Void = set_printer( 'FONTHEADFOOT', font )   
	Void = set_printer( 'HEADER', TheHeader, '', '' )
return

*================================================================================================*
PrintQuoteSpec:
* first prin quote specification information
Lout = 'Q U O T A T I O N / S P E C I F I C A T I O N':fmt('','L#3'):'I N F O R M A T I O N' 
Table = ''
Table<-1> = Lout
TableColInfo = '<+11073'
x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)
Table = ''
Table<-1> = 'Quote#':@vm:'Status':@vm:'Contact Name':@vm:'Contact Phone':@vm:'Contact Fax'
Lout = '' 
Lout := ThisQuote:@vm
Lout := oconv(QuoteRec<quote_status$>,'[QUOTE_STATUS_CONV]'):@vm
Lout := xlate( 'NAMES', QuoteRec<quote_name_no$>, 'FIRST_LAST', 'X' ):@vm
NameRec = xlate( 'NAMES', QuoteRec<quote_name_no$>, '', 'X' )
Tphone = oconv( NameRec<names_phone$,1>, '[PHONE_FORMAT]' )
TExtension   = NameRec<names_phone_ext$,1>
if TExtension then
  TPhone := ' X':Textension
end
Lout := TPhone:@vm
Tfax = oconv( QuoteRec<quote_fax$>, '[PHONE_FORMAT]' )
if Tfax then
   * had a fax on quote so ok
   Lout := Tfax
end else
   * no fax so set it to international fax if blank then it has neither
   Lout := QuoteRec<quote_ifax$>
end
Table<-1> = Lout
TableColInfo = '<+1440':@vm:'<+1440':@fm:'<+2434':@vm:'<+2880':@vm:'<+2880'
x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)
Lout = 'S U B S T R A T E':fmt('','L#3'):'I N F O R M A T I O N' 
Table = ''
Table<-1> = Lout
TableColInfo = '<+11073'
x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)
PSNId = QuoteRec<quote_prod_spec_id$>
SpecSubstrate = xlate( 'PROD_SPEC', PSNId, prod_spec_spec_substrate$, 'X' )
Table = ''
Table<-1> = 'Diameter':@vm:'Type':@vm:'Dopant':@vm:'Orientation':@vm:'Resistivity':@vm:'Bur Lay1':@vm:'Bur Lay2':@vm:'Bur Lay3'
Lout = ''
Lout := SpecSubstrate<1,QSSubWafersize$>:@vm
Lout := SpecSubstrate<1,QSSubType$>:@vm
Lout := SpecSubstrate<1,QSSubDopant$>:@vm
Lout := SpecSubstrate<1,QSSubOrientation$>:@vm
Lout := SpecSubstrate<1,QSSubResistivity$>:@vm
Lout := SpecSubstrate<1,QSSubBl1Dopant$>:@vm
Lout := SpecSubstrate<1,QSSubBl2Dopant$>:@vm
Lout := SpecSubstrate<1,QSSubBl3Dopant$>

Table<-1> = Lout
TableColInfo = '<+1714':@vm:'<+720':@vm:'<+1440':@vm:'<+1440':@vm:'<+1440':@vm:'<+1440':@vm:'<+1440':@vm:'<+1440'
x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)
Lout = 'E P I':fmt('','L#3'):'I N F O R M A T I O N' 
Table = ''
Table<-1> = Lout
TableColInfo = '<+11073'
x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)
EpiLayers = xlate( 'PROD_SPEC', PSNId, prod_spec_spec_epi$, 'X' )
*convert char(247) to @fm in EpiLayers ;* each seperate layer
*SepLCnt = fieldcount( EpiLayers, @fm)
******SEPERATE REACTOR LAYERS*********************************
* NO MORE SEPARATE REACTOR LAYERS DEFINED IN SPEC 
* SO HAD TO MODIFY THIS CODE TO LOOK AT PRIOR psnids AS THESE
* ARE CONSIDERED SEPARATE LAYERS
PrevPSNs = QuoteRec<quote_prev_prod_spec_ids$>
PrevPSNs:= @vm:QuoteRec<quote_prod_spec_id$>
* TACK ON THE PROD_SPEC_ID
PrevPSNs = ex_vm_rem( PrevPSNs )
SepLCnt = fieldcount( PrevPSNs, @vm)
TrueLayer = 0
Table = ''
Table<-1> = 'Layer':@vm:'Dopant':@vm:'Thick Min':@vm:'Thick Max':@vm:'Res Min':@vm:'Res Max'
* print epi layer headings
TableColInfo = '^+1440':@vm:'^+2880':@vm:'^+1699':@vm:'^+1684':@vm:'^+1684':@vm:'^+1684'
x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)
for n = 1 to SepLCnt
   ******SEPERATE REACTOR LAYERS****************************
   TrueLayer += 1
   ThisSepLayer = xlate( 'PROD_SPEC', PrevPSNs<1,n>, prod_spec_spec_epi$, 'X' )
   Table = ''
   Lout = TrueLayer:@vm
   Lout:= ThisSepLayer<1,QSEpiDopant$>:@vm
   Lout:= oconv(ThisSepLayer<1,QSEpiMinThick$>,'MD2'):@vm      
   Lout:= oconv(ThisSepLayer<1,QSEpiMaxThick$>,'MD2'):@vm      
   Lout:= oconv(ThisSepLayer<1,QSEpiResMinThick$>,'MD3'):@vm  
   Lout:= oconv(ThisSepLayer<1,QSEpiResMaxThick$>,'MD3')
   Table<-1> = Lout
   TableColInfo = '^+1440':@vm:'^+2880':@vm:'^+1699':@vm:'^+1684':@vm:'^+1684':@vm:'^+1684'   
   x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)
	******SAME REACTOR LAYERS*********************************
   convert char(248) to @fm in ThisSepLayer
   RestOfLayers = field( ThisSepLayer, @fm, 2, 9999 )
   RolCnt = fieldcount( RestOfLayers, @fm )
   for o = 1 to RolCnt
      TrueLayer += 1
      ThisSameLayer = RestOfLayers<o>
      Table = ''
      Lout = TrueLayer:@vm
      Lout:= ThisSepLayer<1,QSEpiDopant$>:@vm
      Lout:= oconv(ThisSameLayer<1,QSEpiMinThick$>,'MD2'):@vm      
      Lout:= oconv(ThisSameLayer<1,QSEpiMaxThick$>,'MD2'):@vm
      Lout:= oconv(ThisSameLayer<1,QSEpiResMinThick$>,'MD3'):@vm  
      Lout:= oconv(ThisSameLayer<1,QSEpiResMaxThick$>,'MD3')
      Table<-1> = Lout
      TableColInfo = '^+1440':@vm:'^+2880':@vm:'^+1699':@vm:'^+1684':@vm:'^+1684':@vm:'^+1684'         
      x = Set_Printer("ADDTABLE", TableColInfo, '', Table, '', '', 1, TB_ALL)            
   next o ;* same reactor layer
	******END SAME REACTOR LAYERS*****************************
next n ;* seperate reactor layer
*******END SEPERATE REACTOR LAYERS***************************
* NOW PRINT THE QUOTE COMMENTS
if QuoteRec<quote_comments$> <> '' then
   TNote = QuoteRec<quote_comments$>
   convert @tm to ' ' in TNote
   TNote = trim(TNote)
   Table = 'Comments: ':TNote
   TableColInfo = '<+11073'
	x = Set_Printer("ADDTABLE", TableColInfo, '', '', 1, TB_BOX)		   
end
Void = set_printer( 'TEXT', '' )
return
*================================================================================================*

