COMPILE SUBROUTINE Print_Coc_Front( RDSNos, SepLayCnt, Prelim, EmailAddresses, PrintOnly )

DECLARE FUNCTION FieldCount, Msg, Key_Sort, Set_Printer, obj_RDS
DECLARE FUNCTION Calc_WO_Stats

DECLARE SUBROUTINE Btree.Extract

$insert company_equ
$insert coc_equ
$insert email_pENDing_equ
$insert logical
$insert lsl_users_equ
$insert msg_equates
$insert popup_equates
$insert rds_equ
$insert rds_layer_info_equ
$insert quote_equ
$insert quote_spec_equ
$insert oiprint_equates
$insert schedule_equ
$insert security_rights_equ
$insert prod_spec_equ
$insert srp_coc_results_equ





RETURN



Tfont = Font
Tfont<2> = 12
Tfont<3> = 'R'
Tfont<4> = 1
Tfont<6> = 0
Void = set_printer( 'FONT', Tfont )
Void = set_printer( 'TEXT', 'Date: ':oconv( date(), 'D2/' ) )
Void = set_printer( 'TEXT', '' )
Void = set_printer( 'TEXT', '' )
Tfont<2> = 10
Tfont<3> = 'L'
Tfont<4> = 1
Void = set_printer( 'FONT', Tfont )
Void = set_printer( 'TEXT', 'Customer: ':oconv( ThisRdsRec<rds_cust_no$>, '[XLATE_CONV,COMPANY*CO_NAME]' ) )
Addr = xlate( 'COMPANY', ThisRdsRec<rds_cust_no$>, company_address$, 'X' )
Acnt = fieldcount( Addr, @vm )
Void = set_printer( 'TEXT', 'Address: ':Addr<1,1> )
FOR k = 2 to Acnt
    Tvar = fmt( '', 'L#9' ):Addr<1,k>
    Void = set_printer( 'TEXT', Tvar )
NEXT k
Void = set_printer( 'TEXT', '' )
Void = set_printer( 'TEXT', '' )
Tvar = fmt( 'P.O. Number: ':ThisRdsRec<rds_po$>, 'L#65' ):' Part Number: ':ThisRdsRec<rds_part_num$>
Void = set_printer( 'TEXT', Tvar )

* Add the specification information from the PSN

SpecInfo = ''
SpecNums = xlate( 'PROD_SPEC', ThisRdsRec<rds_prod_spec_id$>, prod_spec_spec_num$, 'X' )
convert @vm to ';' in SpecNums
RevNum   = xlate( 'PROD_SPEC', ThisRdsRec<rds_prod_spec_id$>, prod_spec_rev_num$, 'X' )
RevDate  = oconv( xlate( 'PROD_SPEC', ThisRdsRec<rds_prod_spec_id$>, prod_spec_rev_date$, 'X' ), 'D2/' )

IF ( SpecNums <> '' )	THEN SpecInfo:= 'Spec#: ':SpecNums:space(2)
IF ( RevNum <> '' )		THEN SpecInfo:= 'Rev#: ':RevNum:space(2)
IF ( RevDate <> '' )	THEN SpecInfo:= 'Rev Date: ':RevDate:space(2)

SpecInfo[-2,2] = ''

Tvar = fmt( SpecInfo, 'L#68' ):' Quantity: ':CocFrontShipQty
Void = set_printer( 'TEXT', Tvar )
Void = set_printer( 'TEXT', '' )

* lets figure out what layer number to start with

IF i > 1 THEN
    *we are in a sep reactor layer 
    StartingLayerNo = 1
    FOR k = i-1 to 1 step -1
        StartingLayerNo += SameLayCnt<k> + 1
    NEXT k 
END ELSE 
    StartingLayerNo = 1
END

stat = set_printer( 'LINESTYLE', ps_solid:@fm:0 )
* first print base layer
Tfont<2> = 9
Tfont<4> = 0
Tfont<1> = 'MS LineDraw'
Void = set_printer( 'FONT', Tfont )
LineOut = ''
IF StartingLayerNo > 1 THEN
    LineOut := fmt( 'Layer ':StartingLayerNo, 'L#10' )
END
LineOut:= fmt( 'Dopant: ':Dopant, 'L#30' )
LineOut:= fmt( 'Target Thickness ':oconv( ThisRdsRec<rds_thick_target$>, 'MD2' ):ThisRdsRec<rds_thick_units$>, 'L#30' )

IF ThisRdsRec<rds_res_target$> THEN
    LineOut:= fmt( 'Target Resistivity ':oconv( ThisRdsRec<rds_res_target$>, 'MD3' ):ThisRdsRec<rds_res_units$>, 'L#30' )
END ELSE
    LineOut:= 'Target Concentration ':oconv( ThisRdsRec<rds_con_target$,1>, 'MS21' ):ThisRdsRec<rds_con_units$>
    IF ThisRdsRec<rds_con_min$,2> THEN
        LineOut:= ' - ':oconv( ThisRdsRec<rds_con_target$,2>, 'MS21' ):ThisRdsRec<rds_con_units$>
    END
END

Void = set_printer( 'TEXT', LineOut )
StartingLayerNo += 1
FOR k = 1 to SameLayCnt<i>
    LineOut = ''
    IF StartingLayerNo > 1 THEN
        LineOut:= fmt( 'Layer ':StartingLayerNo, 'L#10' )
    END
    Tl = field( ThisRdsRec<rds_layer_info$>, char(248), k )
    Dopant = xlate( 'RDS', ShipRdsKeys<i,1>, 'DOPANT_L':K+1, 'X' )
    LineOut:= fmt( 'Dopant: ':Dopant, 'L#30' )
    LineOut:= fmt( 'Target Thickness ':oconv( Tl<1,RLThickTarget$>, 'MD2' ):Tl<1,RLThickUnits$>, 'L#30' )
    IF Tl<1,RLResTarget$> THEN
        LineOut:= fmt( 'Target Resistivity ':oconv( Tl<1,RLResTarget$>, 'MD3' ):Tl<1,RLResUnits$>, 'L#30' )
    END ELSE
        LineOut:= 'Target Concentration ':oconv( Tl<1,RLConTarget$,1>, 'MS21' ):Tl<1,RLConUnits$>
        IF Tl<1,RLConMin$,2> THEN
            LineOut:= ' - ':oconv( Tl<1,RLConTarget$,2>, 'MS21' ):Tl<1,RLConUnits$>
        END
    END
    Void = set_printer( 'TEXT', LineOut )
    StartingLayerNo += 1
NEXT k

Tfont = Font
Tfont<4> = 0
Tfont<2> = 11
Void = set_printer( 'FONT', Tfont )
Void = set_printer( 'TEXT', '' )
Void = set_printer( 'TEXT', '' )
TextOut = 'The enclosed material has been manufactured, inspected and/or tested in the'
Void = set_printer( 'TEXT', TextOut )
TextOut= 'U.S.A. in accordance with specIFications outlined on your purchase order.'
Void = set_printer( 'TEXT', TextOut )
Void = set_printer( 'TEXT', '' )
Tfont<4> = 1
Void = set_printer( 'FONT', Tfont )
TextOut = 'This material was processed as Work Order Number: ':quote( ThisRdsRec<rds_wo$> ):' and manufactured under process control recipe ':quote( oconv( ThisRdsRec<rds_recipe_no$>, '[XLATE_CONV,RECIPE*RECIPE_NAME]' ) ):'.'
Void = set_printer( 'TEXT', TextOut )
Tfont<4> = 0
Void = set_printer( 'FONT', Tfont )
Void = set_printer( 'TEXT', '' )
TextOut = 'Pertinent test and/or inspection records are on file and available FOR review'

IF PrintBackPage THEN
    Void = set_printer( 'TEXT', TextOut )            
    TextOut = 'under run numbers specIFied in the following page(s) of this document.'
    Void = set_printer( 'TEXT', TextOut )
END ELSE
    TextOut := '.'
    Void = set_printer( 'TEXT', TextOut )
END

FOR k = 1 to 5
    Void = set_printer( 'TEXT', '' )
NEXT k

Void = set_printer( 'TEXT', 'Approved by,' )
FOR k = 1 to 5
    Void = set_printer( 'TEXT', '' )
NEXT k

Tvar = fmt( ' ', 'L#65' )
Tfont<6> = 1
Void = set_printer( 'FONT', Tfont )
Void = set_printer( 'TEXT', Tvar )
Tfont<6> = 0
Void = set_printer( 'FONT', Tfont )
TextOut = fmt( '', 'L#50' ):'Date'
Void = set_printer( 'TEXT', TextOut )
Void = set_printer( 'TEXT', '' )
Void = set_printer( 'TEXT', '' )
TextOut = 'Document Control'
Void = set_printer( 'TEXT', TextOut )

FOR k = 1 to 7
    Void = set_printer( 'TEXT', '' )
NEXT k

Tfont<4> = 1
Void = set_printer( 'FONT', Tfont ) 
TextOut = 'Quality Assurance Registration Number ':quote( ThisRdsRec<rds_wo$> )
Void = set_printer( 'TEXT', TextOut )
Tfont<4> = 0
Void = set_printer( 'FONT', Tfont )
Void = set_printer( 'PAGEBREAK' )
                
RETURN

