COMPILE SUBROUTINE PRINT_PROD_LABELS(RDSNos)


$INSERT LOGICAL
$INSERT MSG_EQUATES
$INSERT REACT_RUN_EQUATES
$INSERT RDS_LAYER_EQUATES
$INSERT RDS_TEST_EQUATES
$INSERT CLEAN_INSP_EQUATES
$INSERT RECIPE_EQU
$INSERT OIPRINT_EQUATES
$INSERT PROD_SPEC_EQUATES
$INSERT QUOTE_SPEC_EQU
$INSERT WO_LOG_EQUATES
$INSERT WO_STEP_EQU
$INSERT WO_MAT_EQUATES
$INSERT ORDER_EQU
$INSERT ORDER_DET_EQU
$INSERT PRS_LAYER_EQU
$INSERT CUST_EPI_PART_EQUATES


DECLARE SUBROUTINE ErrMsg, 
DECLARE FUNCTION MSG, Key_Sort, Get_Printer, Set_Printer, Utility, obj_Install, Printer_Select, obj_Prod_Spec
Declare function    Direct_Print, Environment_Services

* 4/1/2010 cloned from PRINT_CASS_LABELS Change from RDS centric to WO_MAT and expand to 4x4


EQU PI$LEFT		TO	1
EQU PI$TOP		TO  2
EQU PI$RIGHT	TO	3
EQU PI$BOTTOM	TO	4
EQU PI$WIDTH	TO 	5
EQU PI$HEIGHT	TO	6
EQU PI$SIZE		TO	7

IF NOT(ASSIGNED(RDSNos))	THEN RDSNos = ''

ErrorMsg = ''

IF RDSNos = '' 	THEN ErrorMsg = 'Null parameter "RDSNos" passed to routine.'

IF ErrorMsg NE '' THEN
	ErrMsg(ErrorMsg)
	RETURN
END


FileName 	= "Printing Label"
Title		= "Printing Label"

PageInfo	= ''
PageInfo<PI$LEFT>	= 0.1
PageInfo<PI$TOP>	= 0.1
PageInfo<PI$RIGHT>	= 0.1
PageInfo<PI$BOTTOM>	= 0.1

PageSetup	= '1'			;* Landscape
PrintSetup	= ''			;* Preview


*PrinterID = '\\mesirwfp001\MESZBRPRT002'	;* This is the Zebra 105se 
PrinterID  = '\\mesirwfp002\MESZBRPRT004'	;* This is the 105SL - This is the production 1		;* New Zebra 4x4" printer after IFX cutover - dkk 7/29/15


PrintPath	= Printer_Select(PrinterID)		;* Popup is skipped IF Printer ID is passed

If Environment_Services('GetLabelPrintMethod') _EQC 'OIPI' then
    stat = Set_Printer("INIT",FileName,Title,PageInfo,PageSetup,PrintSetup,PrintPath)
end else
    stat = Direct_Print('START', PrintPath<1>, '', '')
end

IF stat < 0 THEN GOTO OIPrint_Error

EQU DosPath$ TO 'C:\WINDOWS\OIZPL.TXT'				;* remove jch

CLOrientation = '' ;* used for printing on cleanroom labels

* Begin data extraction

FirstRunRec = XLATE('REACT_RUN',RDSNos<1,1>,'','X')

WONo = FirstRunRec<REACT_RUN_WO_NO$>
WOStep = FirstRunRec<REACT_RUN_WO_STEP$>

WORec		= XLATE('WO_LOG',WONo,'','X')

WOCassCnt = COUNT(WORec<WO_LOG_WO_MAT_KEY$>,@VM) + (WORec<WO_LOG_WO_MAT_KEY$> NE '')

WOStepKeys = WORec<WO_LOG_WO_STEP_KEY$>

IF INDEX(WOStepKeys,@VM,1) THEN
	PrintWONo = WONo:'.':WOStep
END ELSE
	PrintWONo = WONo
END

WOLogRec = XLATE('WO_LOG',WONo,'','X')

CustNo		= WOLogRec<WO_LOG_CUST_NO$>

CustName	= XLATE('COMPANY',CustNo,'ABBREV_OR_CO_NAME','X')
Captive		= XLATE('COMPANY',CustNo,'CAPTIVE','X')

PONo		= WOLogRec<WO_LOG_CUST_PO_NO$>
EpiPartNo	= WOLogRec<WO_LOG_EPI_PART_NO$>
ReqShipDate	= OCONV(WORec<WO_LOG_PROMISE_SHIP_DT$>,'D2/')

WOStepKeys	= WORec<WO_LOG_WO_STEP_KEY$>
IF Index(WOStepKeys,@VM,1) THEN MultiStep = 1 Else MultiStep = 0

PSNo	= XLATE('WO_STEP',WONo:'*':WOStep,WO_STEP_PROD_SPEC_ID$,'X')
PSRec	= XLATE('PROD_SPEC',PSNo,'','X')

SubOrient		= PSRec<PROD_SPEC_SPEC_SUBSTRATE$,QSSubOrientation$>

CustEpiPartRec	= XLATE('CUST_EPI_PART',CustNo:'*':EpiPartNo,'','X')

ShipBagReq		= CustEpiPartRec<CUST_EPI_PART_SHIP_BAG_REQ$>
ReactType		= OCONV(PSRec<PROD_SPEC_REACTOR_TYPE$>,'[REACT_TYPE_CONV,CODE]')
SpecType		= OCONV( XLATE( 'PROD_SPEC', PSNo, 'SPEC_TYPE', 'X' ), '[SPEC_TYPE_CONV]' )


CustSpecNo = ''
IF Captive THEN
	CustSpecNos		= PSRec<PROD_SPEC_SPEC_NUM$>
	CustSpecDescs	= PSRec<PROD_SPEC_SPEC_DESC$>
	CustSpecRevNos	= PSRec<PROD_SPEC_REV_NUM$>
	CustSpecRevDts	= PSRec<PROD_SPEC_REV_DATE$>
	
	SpecCnt = COUNT(CustSpecNos,@VM) + (CustSpecNos NE '')
	
	FOR I = 1 TO SpecCnt
		IF CustSpecDescs<1,I> _EQC 'GENERAL' THEN
			CustSpecNo		= CustSpecNos<1,I>
			CustSpecDesc	= CustSpecDescS<1,I>
			CustSpecRevNo	= CustSpecRevNos<1,I>
			CustSpecRevDt	= OCONV(CustSpecRevDts<1,I>,'D4/')
		END
	UNTIL CustSpecNo NE ''
	
	NEXT I
END

BoxCnt = COUNT(RDSNos,@FM) + (RDSNos NE '')

GOSUB PrintCleanRoomLabels


* * * * * *
OIPrint_Error:
* * * * * *

If Environment_Services('GetLabelPrintMethod') _EQC 'OIPI' then
    stat = Set_Printer("TERM")
end else
    stat = Direct_Print('STOP')
end

RETURN



* * * * * * * * * * * *`  L o c a l   S u b r o u t i n e s   * * * * * * * * * * * *

* * * * * * *
PrintCleanRoomLabels:
* * * * * * *
 
  
FOR I = 1 TO BoxCnt

	RDSNo  = RDSNos<I>
	
	ReactRunRec = XLATE('REACT_RUN',RDSNo,'','X')
	
	CassNo = ReactRunRec<REACT_RUN_CASS_NO$>
	WOStep = ReactRunRec<REACT_RUN_WO_STEP$>
	
	IF MultiStep THEN
		PrintWONo = WONo:'.':WOStep
	END ELSE
		PrintWONo = WONo
	END
	
	LSKeys = ReactRunRec<REACT_RUN_RDS_LAYER_KEYS$>
	LSCnt = COUNT(LSKeys,@VM) + (LSKeys NE '')
	
	LSIDs = ''
	FOR N = 1 TO LSCnt
		LSIDs<1,-1> = FIELD(LSKeys<1,N>,'*',2)
	NEXT N
	
	WOMatKey = WONo:'*':CassNo
	WOMatRec = XLATE('WO_MAT',WOMatKey,'','X')
	
	LotNo		= WOMatRec<WO_MAT_LOT_NO$>
	WfrQty		= WOMatRec<WO_MAT_WAFER_QTY$>
	CustPartNo	= WOMatRec<WO_MAT_CUST_PART_NO$>
	SubPartNo	= WOMatRec<WO_MAT_SUB_PART_NO$>
	OrderItem	= WOMatRec<WO_MAT_ORDER_ITEM$>
	MakeupBox	= WOMatRec<WO_MAT_MAKEUP_BOX$>
	
	LOCATE CustPartNo IN CustEpiPartRec<CUST_EPI_PART_CUST_PART_NO$> USING @VM SETTING Pos THEN
		CustPartDesc = CustEpiPartRec<CUST_EPI_PART_CUST_PART_DESC$,Pos>
	END ELSE
		CustPartDesc = ''
	END
	
	********************************
	OrderDetKey = WORec<WO_LOG_ORDER_NO$>:'*':OrderItem
	PartNoDesc =  XLATE( 'ORDER_DET',OrderDetKey,'CUST_PN_DESC','X')	;********** This needs checked
	
	SuppCd = SubPartNo[-1,'B-']
	IF LEN(SuppCd) NE '2' THEN SuppCd =''
	
	LSKeys = ReactRunRec<REACT_RUN_RDS_LAYER_KEYS$>
	LSCnt = COUNT(LSKeys,@VM) + (LSKeys NE '')
	
	PrintThickTargets = ''
	PrintResTargets = ''
	PrintConTargets = ''
	PrintCResTargets = ''
	
	
	FOR N = 1 TO LSCnt
	
		LSID = FIELD(LSKeys<1,N>,'*',2)
		
		RDSLayerRec = XLATE('RDS_LAYER',RDSNo:'*':LSID,'','X')
		MetKey		= RDSLayerRec<RDS_LAYER_RDS_TEST_KEYS$,1>	;* Just 1st one
		MetRec		= XLATE('RDS_TEST',MetKey,'','X')
		
		PrintThickTargets<1,N>	= OCONV(MetRec<RDS_TEST_SPEC_THICK_TARGET$>,'MD2'):MetRec<RDS_TEST_SPEC_THICK_UNITS$>
		PrintResTargets<1,N>	= OCONV(MetRec<RDS_TEST_SPEC_RES_TARGET$>,'MD3'):MetRec<RDS_TEST_SPEC_RES_UNITS$>
		PrintConTargets<1,N>	= OCONV(MetRec<RDS_TEST_SPEC_CON_TARGET$>,'MS21'):MetRec<RDS_TEST_SPEC_CON_UNITS$>
		PrintCResTargets<1,N>	= OCONV(MetRec<RDS_TEST_SPEC_CRES_TARGET$>,'MD3'):MetRec<RDS_TEST_SPEC_CRES_UNITS$>
		
		
		IF N = 1 THEN
			RecipeNo	= RDSLayerRec<RDS_LAYER_RECIPE_NO$>
			RecipeInfo	= XLATE( 'RECIPE', RecipeNo, 'RECIPE_NAME_NO', 'X' )
			
			Dopant		= RDSLayerRec<RDS_LAYER_DOPANT$>
		
			ThickMTool		= MetRec<RDS_TEST_SPEC_THICK_MTOOL$>
			ThickMType		= MetRec<RDS_TEST_SPEC_THICK_MTYPE$>
			ThickMRecipe	= MetRec<RDS_TEST_SPEC_THICK_MRECIPE$>
			ThickMFreq		= MetRec<RDS_TEST_SPEC_THICK_MFREQ$>
			ThickMPIType	= MetRec<RDS_TEST_SPEC_THICK_MPROVEIN$>
			ThickMFirst		= MetRec<RDS_TEST_SPEC_THICK_MFIRST$>
			ThickMLast		= MetRec<RDS_TEST_SPEC_THICK_MLAST$>
			ThickMSPC		= MetRec<RDS_TEST_SPEC_THICK_MSPC$>
			ThickMOvergrow	= MetRec<RDS_TEST_SPEC_THICK_MOVERGROW$>
			
			ResMTool		= MetRec<RDS_TEST_SPEC_RES_MTOOL$>
			ResMType		= MetRec<RDS_TEST_SPEC_RES_MTYPE$>
			ResMRecipe		= MetRec<RDS_TEST_SPEC_RES_MRECIPE$>
			ResMFreq		= MetRec<RDS_TEST_SPEC_RES_MFREQ$>
			ResMPIType		= MetRec<RDS_TEST_SPEC_RES_MPROVEIN$>
			ResMFirst		= MetRec<RDS_TEST_SPEC_RES_MFIRST$>
			ResMLast		= MetRec<RDS_TEST_SPEC_RES_MLAST$>
			ResMSPC			= MetRec<RDS_TEST_SPEC_RES_MSPC$>
			ResMOvergrow	= MetRec<RDS_TEST_SPEC_RES_MOVERGROW$>
		
			ConMTool		= MetRec<RDS_TEST_SPEC_CON_MTOOL$>
			ConMType		= MetRec<RDS_TEST_SPEC_CON_MTYPE$>
			ConMRecipe		= MetRec<RDS_TEST_SPEC_CON_MRECIPE$>
			ConMFreq		= MetRec<RDS_TEST_SPEC_CON_MFREQ$>
			ConMPIType		= MetRec<RDS_TEST_SPEC_CON_MPROVEIN$>
			ConMFirst		= MetRec<RDS_TEST_SPEC_CON_MFIRST$>
			ConMLast		= MetRec<RDS_TEST_SPEC_CON_MLAST$>
			ConMSPC			= MetRec<RDS_TEST_SPEC_CON_MSPC$>
			ConMOvergrow	= MetRec<RDS_TEST_SPEC_CON_MOVERGROW$>
			
			CResMTool		= MetRec<RDS_TEST_SPEC_CRES_MTOOL$>
			CResMType		= MetRec<RDS_TEST_SPEC_CRES_MTYPE$>
			CResMRecipe		= MetRec<RDS_TEST_SPEC_CRES_MRECIPE$>
			CResMFreq		= MetRec<RDS_TEST_SPEC_CRES_MFREQ$>
			CResMPIType		= MetRec<RDS_TEST_SPEC_CRES_MPROVEIN$>
			CResMFirst		= MetRec<RDS_TEST_SPEC_CRES_MFIRST$>
			CResMLast		= MetRec<RDS_TEST_SPEC_CRES_MLAST$>
			CResMSPC		= MetRec<RDS_TEST_SPEC_CRES_MSPC$>
			CResMOvergrow	= MetRec<RDS_TEST_SPEC_CRES_MOVERGROW$>
			
			
			BEGIN CASE
				CASE ThickMTool = 'SRP'
					SRPParm			= 'THICK'
					SRPType			= ThickMType
					SRPFirst		= ThickMFirst
					SRPLast			= ThickMLast
					SRPFreq			= ThickMFreq
					
				CASE ResMTool = 'SRP'
					SRPParm			= 'RES'
					SRPType			= ResMType
					SRPFirst		= ResMFirst
					SRPLast			= ResMLast
					SRPFreq			= ResMFreq
					
				CASE ConMTool = 'SRP'
					SRPParm			= 'CON'
					SRPType			= ConMType
					SRPFirst		= ConMFirst
					SRPLast			= ConMLast
					SRPFreq			= ConMFreq
					
				CASE CResMTool = 'SRP'
					SRPParm			= 'CRES'
					SRPType			= CResMType
					SRPFirst		= CResMFirst
					SRPLast			= CResMLast
					SRPFreq			= CResMFreq
					
				CASE 1
					SRPPrintFlag = ''
					SRPParm = ''
					SRPType = ''
					SRPFirst = ''
					SRPLast = ''
					SRPFreq = ''
					

			END CASE
			
		END	;* End of check for First Layer
		
	NEXT N
	
	swap 'æm' with 'um' in PrintThickTargets
	swap 'ê-cm' with 'ohm.cm' in PrintThickTargets
	swap 'ê/Ü' with 'ohm/sq' in PrintThickTargets
	swap '' with 'A' in PrintThickTargets
	 

	swap 'æm' with 'um' in PrintResTargets
	swap 'ê-cm' with 'ohm.cm' in PrintResTargets
	swap 'ê/Ü' with 'ohm/sq' in PrintResTargets
	swap '' with 'A' in PrintResTargets

	
	
	* Thickness print data
	
	PrintThickness = ''
	PrintResistivity = ''
	
	BEGIN CASE
		CASE ThickMFirst AND CassNo = 1			; PrintThickness = 1
		CASE ThickMLast AND CassNo = WOCassCnt	; PrintThickness = 1
		CASE 1
			IF ThickMFreq = 1 THEN
				PrintThickness = 1
			END ELSE
				IF MOD(CassNo,ThickMFreq) = 1 THEN
					PrintThickness = 1
				END
			END
			
	END CASE
	
	IF PrintThickness THEN
		CONVERT '<>' TO '' IN SubOrient
		ThickPrintData = ThickMTool:' ':ThickMType:' ':SubOrient:' ':ThickMRecipe
	END ELSE
		ThickPrintData = ''
		
	END
	
	* Resistivity print data
	
	BEGIN CASE
		CASE ResMFirst AND CassNo = 1			; PrintResistivity = 1
		CASE ResMLast AND CassNo = WOCassCnt	; PrintResistivity = 1
		CASE 1
			IF ResMFreq = 1 THEN
				PrintResistivity = 1
			END ELSE
				IF MOD(CassNo,ResMFreq) = 1 THEN
					PrintResistivity = 1
				END
			END
			
	END CASE
	
	IF PrintResistivity THEN
		CONVERT '<>' TO '' IN SubOrient
		ResPrintData = ResMTool:' ':ResMType:' ':SubOrient:' ':ResMRecipe
	END ELSE
		ResPrintData = ''
	END
	
	
	SRPPrintFlag = ''
	BEGIN CASE
		*CASE SRPParm = 'THICK'	; SRPPrintFlag = 1
		
		*CASE SRPParm = 'RES'	; SRPPrintFlag = 1
		CASE 1
	
			IF SRPFirst	AND CassNo = 1			THEN SRPPrintFlag = 1
			IF SRPLast	AND CassNo = WOCassCnt	THEN SRPPrintFlag = 1
			
			IF SRPFreq = 1 THEN
				SRPPrintFlag = 1
			END ELSE
				IF MOD(CassNo,SRPFreq) = 1 THEN
					SRPPrintFlag = 1
				END
			END
	END CASE
	
	
	PreCINo = ReactRunRec<REACT_RUN_PRE_CI_NO$>
	PreCIRec = XLATE('CLEAN_INSP',PreCINo,'','X')
	
	SubOxide			= OCONV(PreCIRec<CLEAN_INSP_SPEC_CLEAN_SUBOXIDE$>,'B')
	PreCleanTool		= PreCIRec<CLEAN_INSP_SPEC_CLEAN_TOOL$>
	PreAkrionRecipe		= PreCIRec<CLEAN_INSP_SPEC_CLEAN_AKRION_RECIPE$>
	PreSurfscan			= PreCIRec<CLEAN_INSP_SPEC_SURFSCAN$>
	
	
	WfrCINo = ReactRunRec<REACT_RUN_WFR_CI_NO$>
	WfrCIRec = XLATE('CLEAN_INSP',WfrCINo,'','X')
	
	FirstSurfscan		= WfrCIRec<CLEAN_INSP_SPEC_SURFSCAN$>
	
	PostCINo = ReactRunRec<REACT_RUN_POST_CI_NO$>
	PostCIRec = XLATE('CLEAN_INSP',PostCINo,'','X')
	
	IF PostCINo NE '' THEN
		PostCleanTool			= PostCIRec<CLEAN_INSP_SPEC_CLEAN_TOOL$>
		PostAkrionRecipe		= PostCIRec<CLEAN_INSP_SPEC_CLEAN_AKRION_RECIPE$>
		
		PostCleanSurfScan		= PostCIRec<CLEAN_INSP_SPEC_SURFSCAN$>
		PostCleanSSSampleQty	= PostCIRec<CLEAN_INSP_SPEC_SS_SAMP_QTY$>
		PostCleanSurfscanRecipe	= PostCIRec<CLEAN_INSP_SPEC_SURFSCAN_RECIPE$>
		PostCleanSurfDefects	= PostCIRec<CLEAN_INSP_SPEC_SURF_DEFECTS$>
		PostCleanSurfHaze		= OCONV(PostCIRec<CLEAN_INSP_SPEC_SURF_HAZE$>,'MD2')
	END
	
	APreRec  = ''
	APostRec = ''
	IF ( PreAkrionRecipe<1> <> '' ) THEN
		APreRec = ' ':PreAkrionRecipe:' '
		SubOxide = 'No' 					;* If Akrion then no oxide strip
	END

	IF ( PostAkrionRecipe<1> <> '' ) THEN
		APostRec = ' ':PostAkrionRecipe
	END

	PrintCleaningReqs	= TRIM( 'Strip:':SubOxide:' Pre:':PreCleanTool:APreRec:' Post:':PostCleanTool:APostRec )

	GOSUB PrintLabel
	*GOSUB PrintLabel
	
NEXT I
  
RETURN


* * * * * * *
PrintLabel:
* * * * * * *


Str = '^XA'
Str := '^LH0,0'
Str := '^PR2'		;* Print speed 2 inches per second
Str := '^LL812'		;* Label length @203 dpi
Str := '^PW900'
Str := '^MD15'		;* Media darkness
Str := '^MMT'		;* Media mode t=tear off mode
*Str := '^PQ2'		;* Print 2 labels for each pass through here

Str  = '^XA'				;* Start of label format
Str := '^LH20,70'			;* Label home offset (needed to get onto the label medium)
Str := '^BY3'				;* Set narrow Bar Code line width to 3 dots
Str := '^PR2'				;* Print speed = 2 IPS

Str := '^FO15,15^GB795,786,3,B^FS'

* SRP Box and info in Upper Right Corner of label

IF SRPPrintFlag THEN
	Str:= '^FO738,15^GB72,60,3,B^FS'
	Str:= '^FO755,25^A0,25^FDSRP^FS':CRLF$
	
	IF LEN( SRPType ) > 2 THEN
		Str:= '^FO750,50^A0,N,25,^FD':SRPType:'^FS'
	END ELSE
		Str:= '^FO745,50^A0,N,25,^FD':SRPType:'^FS':CRLF$
   END   
END


****** First Line

Company = 'IFX Epi Services'
Str := '^FO30,25^A0,,36^FD':Company:'^FS'


Str := '^FO310,25^AC,18^FDWO No:^FS':CRLF$					;* Label 
Str := '^FO390,25^A045,36^FD':PrintWONo:'^FS':CRLF$			;* Data

IF CassNo = 1 THEN
	
	Str := '^FO550,20^GB90,40,40,,3^FS':CRLF$
	Str := '^FO560,25^AC,18^FR^FDRun:^FS':CRLF$				;* Label 
	Str := '^FO615,25^A045,36^FR^FD':CassNo:'^FS':CRLF$		;* Data
	
END ELSE
	Str := '^FO560,25^AC,18^FDRun:^FS':CRLF$				;* Label 
	Str := '^FO615,25^A045,36^FD':CassNo:'^FS':CRLF$		;* Data
END


****** Second Line

Str:= '^FO30,70^AC,18^FDRDS:^FS':CRLF$
Str:= '^FO90,70^A050,30^FD':RDSNo:'^FS':CRLF$

Str := '^BY2,2.0':CRLF$
Str := '^FO200,70^B3,,23,N^FD':RDSNo:'^FS':CRLF$
Str := '^BY2,3.0':CRLF$

Str:= '^FO450,70^AC,18^FDQty:^FS':CRLF$						;* Label
Str:= '^FO510,70^A045,25^FD':WfrQty:'^FS':CRLF$				;* Data

IF MakeupBox THEN
	Str := '^FO575,65^GB140,35,35,,3^FS':CRLF$
	Str := '^FO585,70^A0,,35^FR^FDM/U Box^FS'
END


****** Third Line

Str:= '^FO30,105^AC,18^FDShip Dt:^FS'	;* Label
Str:= '^FO140,105^A0,,25^FD':ReqShipDate:'^FS':CRLF$		;* Data

Str:= '^FO250,105^AC,18^FDCust:^FS':CRLF$					;* Label
Str:= '^FO320,105^A045,25^FD':CustName:'^FS':CRLF$			;* Data

Str:= '^FO560,105^AC,18^FDPO:^FS':CRLF$
Str:= '^FO600,105^A045,25^FD':PONo:'^FS':CRLF$


****** Separator bar

Str:= '^FO15,128^GB795,1^FS'


****** Fourth Line

LineY = 135

Str := '^FO30,':LineY:'^AC,18^FDLot No:^FS':CRLF$
Str := '^FO120,':LineY:'^A0,20^FD':LotNo:'^FS':CRLF$



****** Fifth Line

LineY += 25

Str := '^FO30,':LineY:'^AC,18^FDSub PN:^FS':CRLF$
Str := '^FO120,':LineY:'^A0,20^FD':SubPartNo:'^FS':CRLF$

IF SuppCd NE '' THEN

	Str := '^FO410,':LineY:'^AC,18^FDSupp Cd:^FS':CRLF$			;* Label			;* Added 8/17/2005 JCH - J.C.Henry & Co.
	Str := '^FO510,':LineY:'^A0,20^FD':SuppCd:'^FS':CRLF$		;* Data
	
	Str := '^BY2,2.0':CRLF$
	Str := '^FO610,':LineY:'^A040,20^B3,,23,N^FD':SuppCd:'^FS':CRLF$
	Str := '^BY2,3.0':CRLF$
END


****** New Part Number line

LineY += 25

Str := '^FO30,':LineY:'^AC,18^FDCust Part No:^FS':CRLF$
Str := '^FO200,':LineY:'^A0,20^FD':CustPartNo:' ':CustPartDesc:'^FS':CRLF$


****** Customer Spec Line

LineY += 25

IF CustSpecNo NE '' THEN

	Str := '^FO30,':LineY:'^AC,18^FDCust Spec No:^FS':CRLF$
	Str := '^FO200,':LineY:'^A0,20^FD':CustSpecNo:' ':CustSpecDesc:'^FS':CRLF$

	Str := '^FO475,':LineY:'^AC,18^FDRev:^FS':CRLF$
	Str := '^FO525,':LineY:'^A0,20^FD':CustSpecRevNo:'^FS':CRLF$

	Str := '^FO615,':LineY:'^AC,18^FDRev Dt:^FS':CRLF$
	Str := '^FO700,':LineY:'^A0,20^FD':CustSpecRevDt:'^FS':CRLF$

END

****** Separator bar

LineY += 23

Str := '^FO15,':LineY:'^GB795,1^FS'


****** Sixth Line

LineY += 7

Str := '^FO30,':LineY:'^AC,18^FDStrip Oxide:^FS':CRLF$
Str := '^FO180,':LineY:'^A0,20^FD':SubOxide:'^FS':CRLF$

Str := '^FO410,':LineY:'^AC,18^FDReact Type:^FS':CRLF$
Str := '^FO560,':LineY:'^A0,20^FD':ReactType:'^FS':CRLF$

****** Seventh Line

LineY += 25

Str := '^FO30,':LineY:'^AC,18^FDPre:^FS':CRLF$
Str := '^FO90,':LineY:'^A0,20^FD':PreCleanTool:'^FS':CRLF$

LineY += 25

IF PreAkrionRecipe NE '' THEN
	Str := '^FO30,':LineY:'^AC,18^FDAkrion:^FS':CRLF$
	Str := '^FO120,':LineY:'^A0,20^FD':PreAkrionRecipe:'^FS':CRLF$

	Str := '^BY2,2.0':CRLF$
	Str := '^FO400,':LineY:'^A040,20^B3,,23,N^FD':PreAkrionRecipe:'^FS':CRLF$
	Str := '^BY2,3.0':CRLF$
END


****** Eighth Line

LineY += 35

Str := '^FO30,':LineY:'^AC,18^FDRecipe:^FS':CRLF$
Str := '^FO120,':LineY:'^A0,20^FD':RecipeInfo:'^FS':CRLF$

Str := '^FO410,':LineY:'^AC,18^FDEpi Dopant:^FS':CRLF$
Str := '^FO560,':LineY:'^A040,20^FD':Dopant:'^FS':CRLF$


****** Ninth Line

LineY += 25

Str := '^FO30,':LineY:'^A040,20^FD':ThickPrintData:'^FS':CRLF$
Str := '^FO410,':LineY:'^A040,20^FD':ResPrintData:'^FS':CRLF$


****** Tenth, Eleventh and Twelfth Lines

LineY += 25

Str := '^FO30,':LineY:'^AC,18^FDThk Spec:^FS':CRLF$

FOR M = 1 TO COUNT(PrintThickTargets,@VM) + (PrintThickTargets NE '')
	BaseLine = LineY + (M-1)*20
	Str := '^FO140,':BaseLine:'^A040,20^FD':PrintThickTargets<1,M>:'^FS':CRLF$
NEXT M


Str := '^FO410,':LineY:'^AC,18^FDRes Spec:^FS':CRLF$

FOR M = 1 TO COUNT(PrintResTargets,@VM) + (PrintResTargets NE '')
	BaseLine = LineY + (M-1)*20
	Str := '^FO520,':BaseLine:'^A040,20^FD':PrintResTargets<1,M>:'^FS':CRLF$
NEXT M

LineY = 625


****** Line

	Str := '^FO30,625^AC,18^FDPost:^FS':CRLF$
	Str := '^FO120,625^A0,20^FD':PostCleanTool:'^FS':CRLF$
	
	IF PostAkrionRecipe NE '' THEN
		
		Str := '^FO30,650^AC,18^FDAkrion:^FS':CRLF$
		Str := '^FO120,650^A0,20^FD':PostAkrionRecipe:'^FS':CRLF$
		
		Str := '^BY2,2.0':CRLF$
		Str := '^FO400,650^A040,20^B3,,23,N^FD':PostAkrionRecipe:'^FS':CRLF$
		Str := '^BY2,3.0':CRLF$
	END


****** Line 13

PostCleanSSSampleQty	= PostCIRec<CLEAN_INSP_SPEC_SS_SAMP_QTY$>
PostCleanSurfscanRecipe	= PostCIRec<CLEAN_INSP_SPEC_SURFSCAN_RECIPE$>
PostCleanSurfDefects	= PostCIRec<CLEAN_INSP_SPEC_SURF_DEFECTS$>
PostCleanSurfHaze		= OCONV(PostCIRec<CLEAN_INSP_SPEC_SURF_HAZE$>,'MD2')


IF PostCleanSurfScanRecipe NE '' THEN
	LineY = 685
	Str := '^FO30,':LineY:'^AC,18^FDSample:^FS':CRLF$
	Str := '^FO120,':LineY:'^A0,20^FD':PostCleanSSSampleQty:'^FS':CRLF$

	Str := '^FO200,':LineY:'^AC,18^FDSum of Defects:^FS':CRLF$
	Str := '^FO390,':LineY:'^A0,20^FD':PostCleanSurfDefects:'^FS':CRLF$
	
	Str := '^FO450,':LineY:'^AC,18^FDHaze Avg:^FS':CRLF$
	Str := '^FO570,':LineY:'^A0,20^FD':PostCleanSurfHaze:'^FS':CRLF$
	
	Str := '^FO30,710^AC,18^FDTencor:^FS':CRLF$
	Str := '^FO120,710^A0,20^FD':PostCleanSurfScanRecipe:'^FS':CRLF$
	
	Str := '^BY2,2.0':CRLF$
	Str := '^FO350,710^A040,20^B3,,23,N^FD':PostCleanSurfScanRecipe:'^FS':CRLF$
	Str := '^BY2,3.0':CRLF$
	
	*Str := '^FO30,700^AC,18^FDPost:^FS':CRLF$
	*Str := '^FO90,700^A0,20^FD':PostCleanTool:'^FS':CRLF$
END



****** Separator bar

Str := '^FO15,738^GB795,1^FS'


****** Lines 15 and 16

Str := '^FO30,775^AC,18^FDProd Spec No:^FS':CRLF$			;* Label
Str := '^FO190,775^A0,25^FD':PSNo:'^FS':CRLF$				;* Data


IF SpecType = 'Production' THEN SpecType = 'Prod'
IF SpecType = 'Pre-Production' THEN SpecType = 'Pre'

Str := '^FO275,775^AC,18^FDSpec Type:^FS':CRLF$				;* Label
Str := '^FO400,775^A0,25^FD':SpecType:'^FS':CRLF$		;* Data


Str:= '^FO30,750^AC,18^FDBag:^FS':CRLF$
Str:= '^FO80,750^A0,20^FD':ShipBagReq:'^FS':CRLF$


Str:= '^XZ'

If Environment_Services('GetLabelPrintMethod') _EQC 'OIPI' then
    stat = Set_Printer('TEXT',Str)
end else
    stat = Direct_Print('PRINT', Str)
end
	
RETURN	


* * * * * * *
PrintWOLabels:
* * * * * * *

* Got all data now we can print 
    
RDSCnt = COUNT(RDSNos,@VM) + (RDSNos NE '')
ShelfCnt = INT(RDSCnt/28) + (MOD(RDSCnt,28) NE 0)		;* Come back TO this later JCH 7/27/2005


* So we print two sets of labels           	         


GOSUB PrintWO
GOSUB PrintWO

   
RETURN


* * * * * * *
PrintWO:
* * * * * * *

Str = '^XA^CFD'
Str:= '^LH0,0'
Str:= '^PR2' 		;* PRINT SPEED 2 INCHES PER SECOND
Str:= '^LL325' 		;* LABEL LENGTH IN DOTS
Str:= '^MD15' 		 ;* MEDIA DARKNESS
Str:= '^MMT':CRLF$   ;* MEDIA MODE T=TEAR OFF MODE

IF MultiStep > 0 THEN
	Str:= '^FO10,30^A0220,210^FD':PrintWONo:'^FS':CRLF$	 		;* 5/21/2005 - JCH - Changed for Order Entry/Vision upgrade
END ELSE
	Str:= '^FO70,30^A0220,210^FD':PrintWONo:'^FS':CRLF$	 		
END

* Get Cust Abbrev

CharCnt = LEN(CustName)
NameLength = CharCnt*72
WhiteSpace = INT(((2103 - NameLength)/2103) * 806)
StartingXPos = INT(WhiteSpace/2)

Str:= '^FO':StartingXPos:',230^A0,75,72^FD':CustName:'^FS':CRLF$


*Str:= '^FO150,320^A080,50^FD':'Commit Date: ':OCONV( XLATE( 'WO_LOG', PrintUniqueWO[1,'.'], wo_log_commit_date$, 'X' ), 'D2/' ):'^FS':CRLF$
Str:= '^XZ'


If Environment_Services('GetLabelPrintMethod') _EQC 'OIPI' then
    stat = Set_Printer('TEXT',Str)
end else
    stat = Direct_Print('PRINT', Str)
end

RETURN



* * * * * * *
PrintMonitorLabels:
* * * * * * *

FOR I = 1 TO IdCnt

	Str = '^XA^CFD'
	Str:= '^LH0,0'
	Str:= '^PR2' ;* PRINT SPEED 2 INCHES PER SECOND
	Str:= '^LL325' ;* LABEL LENGTH IN DOTS
	Str:= '^MD15'  ;* MEDIA DARKNESS
	Str:= '^MMT':CRLF$   ;* MEDIA MODE T=TEAR OFF MODE
	Str:= '^FO30,30^A060,40^FDMonitor Wafer^FS':CRLF$
	Str:= '^FO550,30^A060,40^FDReactor#_____^FS':CRLF$
	Str:= '^FO30,70^A060,40^FDDate_____________^FS':CRLF$
	Str:= '^FO30,130^A060,40^FDCustomer Name: ':CustName<I>:'^FS':CRLF$
	Str:= '^FO30,190^A060,40^FDRDS#: ':RDSIds<I>:'^FS':CRLF$
	Str:= '^FO400,190^A060,40^FDLot#: ':LotNum<I>:'^FS':CRLF$
	Str:= '^FO30,250^A060,40^FDThick Avg__________^FS':CRLF$
	Str:= '^FO400,250^A060,40^FDWafer Type__________^FS':CRLF$		
	Str:= '^FO30,280^A060,40^FDRes   Avg____________^FS':CRLF$
	Str:= '^FO400,280^A060,40^FDWafer Type__________^FS':CRLF$
	Str:= '^XZ'
	
    If Environment_Services('GetLabelPrintMethod') _EQC 'OIPI' then
        stat = Set_Printer('TEXT',Str)
    end else
        stat = Direct_Print('PRINT', Str)
    end
		
NEXT I

RETURN


* * * * * * *
PrintSurfscanLabels:
* * * * * * * 

FOR I = 1 TO IdCnt
	Str = '^XA^CFD'
	Str:= '^LH0,0'
	Str:= '^PR2' ;* PRINT SPEED 2 INCHES PER SECOND
	Str:= '^LL325' ;* LABEL LENGTH IN DOTS
	Str:= '^MD15'  ;* MEDIA DARKNESS
	Str:= '^MMT'   ;* MEDIA MODE T=TEAR OFF MODE
	Str:= '^FO30,30^A060,40^FDSurfscan Required^FS'
	*Str:= '^FO550,30^A060,40^FDRDS#':RDSIds<I>:'^FS'
	IF PreSurfscan THEN
	   Str:= '^FO30,130^A060,40^FDPre Epi:^FS'
	   Str:= '^FO250,130^A060,40^FDDefects________^FS'
	   Str:= '^FO500,130^A060,40^FDHaze________^FS'	   
	END
	IF FirstSurfscan THEN
	   Str:= '^FO30,190^A060,40^FDFirst Wafer^FS'
	   Str:= '^FO250,190^A060,40^FDDefects________^FS'
	   Str:= '^FO500,190^A060,40^FDHaze________^FS'	   
	END
	IF PostCleanSurfscan THEN
	   Str:= '^FO30,250^A060,40^FDPost Epi:^FS'
	   Str:= '^FO250,250^A060,40^FDDefects________^FS'
	   Str:= '^FO500,250^A060,40^FDHaze________^FS'	   
	END		
	Str:= '^XZ'
	
    If Environment_Services('GetLabelPrintMethod') _EQC 'OIPI' then
        stat = Set_Printer('TEXT',Str)
    end else
        stat = Direct_Print('PRINT', Str)
    end
	
	
NEXT I


RETURN





