COMPILE SUBROUTINE PRINT_CASS_LABELS( RdsIds , MultiStep )
#pragma precomp SRP_PreCompiler

$INSERT LOGICAL
$INSERT MSG_EQUATES
$INSERT RDS_EQUATES
$INSERT RDS_LAYER_INFO_EQU
$INSERT OIPRINT_EQUATES
$INSERT PROD_SPEC_EQUATES
$INSERT QUOTE_SPEC_EQU
$INSERT WO_LOG_EQUATES
$INSERT WO_MAT_EQUATES
$INSERT ORDER_DET_EQU
$INSERT EPI_PART_EQUATES
$INSERT COMPANY_EQUATES
$INSERT CUST_EPI_PART_EQUATES
$INSERT PRS_STAGE_EQUATES

DECLARE FUNCTION FIELDCOUNT, MSG, Key_Sort, Get_Printer, SRP_Math, Set_Printer, Utility, obj_Install, Printer_Select, obj_Vendor_Code, Direct_Print, Environment_Services
DECLARE SUBROUTINE Extract_Si_Keys, Update_Index, ErrMsg

/*
* 269203   Medtronic with long Lot No
* 281102   IR with longwinded Part/Substrate part Number
* 228212	IR Multilayerd

* * * * * *
* added 9/10/2003 - J.C. Henry, changed printdriver to generic
* eliminated port capture to print, changed printing OI Print Interface 
*
* added 10/18/2005 - J.C. Henry - changed label size to 2" x 4" for Akrion Bar Codes and general rearrangement
*       10/26/20    DPC     added CheatSheatLabel routine
*       10/01/21	DPC		changed PrintLabel routine - instead of just printing 2 labels (^PQ2), now loop in order
*							to print label number identifier in datamatrix barcode (e.g., SEQ1, SEQ2)
*/

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

EQU PS$TOOL		TO 1
EQU PS$TYPE		TO 2
EQU PS$RECIPE	TO 3
EQU PS$FREQ		TO 4
EQU PS$PATTERN	TO 11

IF NOT(ASSIGNED(RdsIds))	THEN RdsIds = ''				;* 5/21/2005 - JCH - Added for Order Entry/Vision upgrade
IF NOT(ASSIGNED(MultiStep))	THEN MultiStep = ''				;* 5/21/2005 - JCH - Added for Order Entry/Vision upgrade

IF RdsIds = '' 		THEN RETURN 0							;* 5/21/2005 - JCH - Added for Order Entry/Vision upgrade
IF MultiStep = ''	THEN MultiStep = 0						;* 5/21/2005 - JCH - Added for Order Entry/Vision upgrade

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 = ''
PrintPath	= Printer_Select(PrinterID)												;* Popup is skipped IF Printer ID is passed

If PrintPath NE '' then
	
	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
	
	IF RdsIds THEN
		Update_Index ("RDS", "WO", "")
		Void = utility( 'CURSOR', 'H' )
		IdCnt = fieldcount( RdsIds, @FM )
		* sort by run order number
		IF IdCnt > 1 THEN
			RdsIds = key_sort( RdsIds, 'RDS', 'WO':@FM:'RUN_ORDER_NUM', 1, '', '' )
		END
		
		// To work around the design flaws in the label printing logic regarding multiple RDS Key IDs
		// while still preserving the variable names, the RdsIds values will be transferred to AllRdsIds
		// and then each RDS Key ID will be parsed in a loop and passed into the RdsIds variable.
		Transfer RdsIds to AllRdsIds
		For Each RdsIds in AllRdsIds using @FM
			IdCnt       = fieldcount( RdsIds, @FM )
			GOSUB PrintCleanRoomLabels
		Next RdsIds
		
		// Restore RdsIds variable for other processes that need it to be intact.
		Transfer AllRdsIds to RdsIds
		
		UniqueWOs       = ''
		CustNos         = ''
		CompositeKeys   = ''
		IdCnt           = fieldcount( RdsIds, @FM )

		IF MultiStep > 0 THEN
			
			WOStepKeys = XLATE('RDS',RdsIds,RDS_WO_STEP_KEY$,'X')			;* 5/21/2005 - JCH - Added for Order Entry/Vision upgrade
			FOR I = 1 TO IdCnt
				ThisWO = WOStepKeys<I>
				CONVERT '*' TO '.' IN ThisWO
				CassNo          = XLATE('RDS',RdsIds<I>,'CASS_NO','X')
				WOMatRec	    = XLATE('WO_MAT',ThisWO:'*':CassNo,'','X')
				ReShipCustNo    = WOMatRec<WO_MAT_RESHIP_CUST_NO$>
				If ReShipCustNo EQ '' then
					CustNo  = XLATE( 'WO_LOG', ThisWO, wo_log_cust_no$, 'X' )
				end else
					CustNo  = ReShipCustNo
				end
				LOCATE ThisWO : '*' : CustNo IN CompositeKeys USING @VM SETTING FPos ELSE
					UniqueWOs<1,-1> = ThisWO
					CustNos<1,-1> = CustNo
					CompositeKeys<1,-1> = ThisWO : '*' : CustNo
				END
			NEXT I
			
		END ELSE
			
			AllWOs = XLATE( 'RDS', RdsIds, rds_wo$, 'X' )
			FOR I = 1 TO IdCnt
				ThisWO          = AllWOs<I>
				CassNo          = XLATE('RDS',RdsIds<I>,'CASS_NO','X')
				WOMatRec	    = XLATE('WO_MAT',ThisWO:'*':CassNo,'','X')
				ReShipCustNo    = WOMatRec<WO_MAT_RESHIP_CUST_NO$>
				If ReShipCustNo EQ '' then
					CustNo  = XLATE( 'WO_LOG', ThisWO, wo_log_cust_no$, 'X' )
				end else
					CustNo  = ReShipCustNo
				end
				LOCATE ThisWO : '*' : CustNo IN CompositeKeys USING @VM SETTING Fpos ELSE
					UniqueWOs<1,-1> = ThisWO
					CustNos<1,-1> = CustNo
					CompositeKeys<1,-1> = ThisWO : '*' : CustNo
				END 
			NEXT I
			
		END
		
		GOSUB PrintWOLabels			;* Activated WO label printing again -dkk 12/3/14
		
		WONo	= XLATE('RDS',RdsIds<1>,RDS_WO$,'X')
		CustNo	= XLATE('WO_LOG',WONo,WO_LOG_CUST_NO$,'X')
		Void = UTILITY( 'CURSOR', 'A' )            
	END
	
	* * * * * *
	OIPrint_Error:
	* * * * * *
	
	If Environment_Services('GetLabelPrintMethod') _EQC 'OIPI' then
		stat = Set_Printer("TERM")
	end else
		stat = Direct_Print('STOP')
	end
end

RETURN

* * * * * * * * * * * *  Local Subroutines  * * * * * * * * * * * *

* * * * * * *
PrintCleanRoomLabels:
* * * * * * *
	// Note: Due to code changes in the calling logic for this gosub, the RdsIds variable actually only
	// contains one RDS Key ID at a time.
	WO					= XLATE( 'RDS', RdsIds, rds_wo$, 'X' )
	WOLogRec 			= XLATE('WO_LOG',WO,'','X')
	
	CassNos             = XLATE('RDS',RdsIds,'CASS_NO','X')
	CassNo              = CassNos<1>
	WOMatRec	        = XLATE('WO_MAT',WO:'*':CassNo,'','X')
	ReShipCustNo        = WOMatRec<WO_MAT_RESHIP_CUST_NO$>
	ReShipDate          = WOMatRec<WO_MAT_RESHIP_DT$>
	ReShipCustEpiPartNo = WOMatRec<WO_MAT_RESHIP_CUST_EPI_PART_NO$>
	ReShipCustPO        = WOMatRec<WO_MAT_RESHIP_CUST_PO$>
	ReShipCustPartNo    = WOMatRec<WO_MAT_RESHIP_CUST_PART_NO$>
	
	If ReShipCustNo EQ '' then
		CustNo		= WOLogRec<WO_LOG_CUST_NO$>
		CustName	= XLATE( 'RDS', RdsIds, 'ABBREV_OR_CO_NAME', 'X' )
		CustName = XLATE( 'COMPANY', CustNo, 'ABBREV_OR_CO_NAME', 'X' )
	end else
		CustNo      = ReShipCustNo
		CompRec		= XLATE('COMPANY',CustNo,'','X')
		CustName    = CompRec<COMPANY_ABBREV$>
	end
	
	If ReShipCustEpiPartNo EQ '' then
		EpiPartNo   = WOLogRec<WO_LOG_EPI_PART_NO$>
	end else
		EpiPartNo   = ReShipCustEpiPartNo
	end
	
	EpiPartRec			= XLATE('EPI_PART',EpiPartNo,'','X')
	CustEpiPartRec		= XLATE('CUST_EPI_PART',CustNo:'*':EpiPartNo,'','X')
	CustEpiPartSpecNo	= CustEpiPartRec<CUST_EPI_PART_SPEC_NO$>[-1,'B':@VM]	;* Last (current) Customer Spec Number
	
	ShipBagReq			= CustEpiPartRec<CUST_EPI_PART_SHIP_BAG_REQ$>
	
	If ReShipDate EQ '' then
		ReqShipDate		= OCONV( XLATE( 'WO_LOG', WO, WO_LOG_PROMISE_SHIP_DT$, 'X' ), 'D2/' )
	end else
		ReqShipDate     = ReShipDate
	end
	
	If ReShipCustPO EQ '' then
		IF CustNo = '7108' THEN
			PO  = ''							;* Changed for "Foundry" customer additions 8/28/2012 JCH **********
		END ELSE
			PO	= XLATE( 'RDS', RdsIds, rds_po$, 'X' )
		END
	end else
		PO  = ReShipCustPO
	end
	
	If ReShipCustPartNo EQ '' then
		PartNum	= XLATE( 'RDS', RdsIds, rds_part_num$, 'X' )
	end else
		PartNum = ReShipCustPartNo
	end
	
	ThickTarget			= OCONV( XLATE( 'RDS', RdsIds, 'THICK_TARGET_ALL', 'X' ), 'MD3' )
	ThickUnit			= XLATE( 'RDS', RdsIds, 'THICK_UNITS_ALL', 'X' )
	Dopant				= XLATE( 'RDS', RdsIds, 'DOPANT_L1', 'X' )
	ResTarget			= OCONV( XLATE( 'RDS', RdsIds, 'RES_TARGET_ALL', 'X' ), 'MD3' )
	ResUnit				= XLATE( 'RDS', RdsIds, 'RES_UNITS_ALL', 'X' )
	RecipeIDS			= XLATE( 'RDS', RdsIds, 'RECIPE_NO', 'X' )
	LotNum				= XLATE( 'RDS', RdsIds, rds_lot_num$, 'X' )
	RONum				= XLATE( 'RDS', RdsIds, 'RUN_ORDER_NUM', 'X' )
	PSNIds				= XLATE( 'RDS', RdsIds, rds_prod_spec_id$, 'X' )
	SpecType			= OCONV( XLATE( 'RDS', RdsIds, 'SPEC_TYPE', 'X' ), '[SPEC_TYPE_CONV]' )
	SubPartNum			= XLATE( 'RDS', RdsIds, 'SUB_PART_NUM', 'X' )
	
	RecipeInfo			= XLATE( 'RECIPE', RecipeIDS, 'RECIPE_NAME_NO', 'X' )
	
	ThickVar			= XLATE( 'PROD_SPEC', PSNIds, 'THICK_MEASURE_L1', 'X' )
	ResVar				= XLATE( 'PROD_SPEC', PSNIds, 'RES_MEASURE_L1', 'X' )
	ConVar				= XLATE( 'PROD_SPEC', PSNIds, 'CON_MEASURE_L1', 'X' )
	StressVar			= XLATE( 'PROD_SPEC', PSNIds, 'STRESS_MEASURE', 'X' )
	TransVar			= XLATE( 'PROD_SPEC', PSNIds, 'TRANS_MEASURE', 'X' )
	ReactTypes			= OCONV( XLATE( 'PROD_SPEC', PSNIds, 'REACTOR_TYPE', 'X' ), '[REACT_TYPE_CONV,CODE]')
	SubOxide			= OCONV(EpiPartRec<EPI_PART_SUB_OXIDE$>,'B')
	
	SubPreCleans		= ''
	SubPostCleans		= ''
	PreAkrionRecipes	= ''
	PostAkrionRecipes	= ''
	
	PSNCnt = COUNT(PSNIds,@FM) + (PSNIds NE '')
	
	FOR I = 1 TO PSNCnt
		PSNId = PSNIds<I>
		SubPreCleans<I>			= XLATE('PRS_STAGE',PSNId:'*PRE','TOOL_DISPLAY','X')
		SubPostCleans<I>		= XLATE('PRS_STAGE',PSNId:'*POST','TOOL_DISPLAY','X')
		PreAkrionRecipes<I>		= XLATE('PRS_STAGE',PSNId:'*PRE',PRS_STAGE_CLEAN_RECIPE$,'X')
		PostAkrionRecipes<I>	= XLATE('PRS_STAGE',PSNId:'*POST',PRS_STAGE_CLEAN_RECIPE$,'X')
	NEXT I
	
	SWAP 'AKRION' WITH 'Akr' IN SubPreCleans
	SWAP 'AKRION' WITH 'Akr' IN SubPostCleans
	
	SWAP ' or ' WITH '/' IN SubPreCleans
	SWAP ' or ' WITH '/' IN SubPostCleans												;* To wide for field on small label "squeezed" data to fit JCH
	
	SubPartNum			= XLATE( 'RDS', RdsIds, 'SUB_PART_NUM', 'X' )
	WOStepKeys			= XLATE( 'RDS',RdsIds,RDS_WO_STEP_KEY$,'X' )							;* 05/21/2005 - JCH - Added for Order Entry/Vision upgrade
	
	IF CustNo = '7108' THEN
		CustPNDescs = ''																		;* 8/28/2012 - JCH Added for new "Foundry" customer ******************
	END ELSE
		CustPNDescs	= XLATE('EPI_PART',EpiPartNo,EPI_PART_EPI_PART_DESC$,'X')					;* 12/2/2011 - JCH Added for SAP interface
	END
	
	************************************
	PreSurfscan			= XLATE( 'PRS_STAGE', PSNIds<1>:'*PRE' , PRS_STAGE_SURFSCAN_SIG_REQ$ , 'X' )
	FirstSurfscan		= XLATE( 'PRS_STAGE', PSNIds<1>:'*FWI' , PRS_STAGE_SURFSCAN_SIG_REQ$ , 'X' )
	PostCleanSurfscan	= XLATE( 'PRS_STAGE', PSNIds<1>:'*POST' , PRS_STAGE_SURFSCAN_SIG_REQ$ , 'X' )
	
	CleaningReqs		= ''
	
	SRPFlag				= XLATE( 'PROD_SPEC', PSNIds, 'SRP_REQ', 'X' )			;* Updated in PROD_SPEC dictionary JCH 4/21/2015
	Qtys 				= XLATE( 'RDS', RdsIds, 'WAFERS_SCHEDULED', 'X' )
	MultilayVar			= XLATE( 'RDS', RdsIds, 'MULTI_LAYER', 'X' )
	
	* Lets break out thick and res and see if it gets measured based on frequency
	* Thickness
	
	ThickPrintVar = ''
	ResPrintVar   = ''
	SRPPrintVar   = ''
	SRPTypePrintVar = ''  
	
	FOR I = 1 TO IdCnt
		
		ThisThickVar  = ThickVar<I>
		ThisResVar    = ResVar<I>
		ThisConVar    = ConVar<I>
		ThisStressVar = StressVar<I>
		ThisTransVar  = TransVar<I>
		ThisRunOrdNum = RONum<I>
		ThisWO        = WO<I>
		ThisWOStepKey = WOStepKeys<I>								;* 5/21/2005 - JCH - Added for Order Entry/Vision upgrade
		IF MultiStep > 0 THEN ThisWO = ThisWOStepKey[1,'*']			;* 5/21/2005 - JCH - Added for Order Entry/Vision upgrade	
		
		ThickTool   = field( ThisThickVar, '~', 1 )
		ThickType   = field( ThisThickVar, '~', 2 )
		ThickRecipe = field( ThisThickVar, '~', 3 )
		ThickFreq   = field( ThisThickVar, '~', 4 )
		ThickFirst  = field( ThisThickVar, '~', 6 )
		ThickLast   = field( ThisThickVar, '~', 7 )
		
		ResTool   = field( ThisResVar, '~', 1 )
		ResType   = field( ThisResVar, '~', 2 )
		ResRecipe = field( ThisResVar, '~', 3 )
		ResFreq   = field( ThisResVar, '~', 4 )
		ResFirst  = field( ThisResVar, '~', 6 )
		ResLast   = field( ThisResVar, '~', 7 )
		
		ConTool   = field( ThisConVar, '~', 1 )
		ConType   = field( ThisConVar, '~', 2 )
		ConRecipe = field( ThisConVar, '~', 3 )
		ConFreq   = field( ThisConVar, '~', 4 )
		ConFirst  = field( ThisConVar, '~', 6 )
		ConLast   = field( ThisConVar, '~', 7 )
		
		StressTool   = field( ThisStressVar, '~', 1 )
		StressType   = field( ThisStressVar, '~', 2 )
		StressRecipe = field( ThisStressVar, '~', 3 )
		StressFreq   = field( ThisStressVar, '~', 4 )
		StressFirst  = field( ThisStressVar, '~', 6 )
		StressLast   = field( ThisStressVar, '~', 7 )
		
		TransTool   = field( ThisTransVar, '~', 1 )
		TransType   = field( ThisTransVar, '~', 2 )
		TransRecipe = field( ThisTransVar, '~', 3 )
		TransFreq   = field( ThisTransVar, '~', 4 )
		TransFirst  = field( ThisTransVar, '~', 6 )
		TransLast   = field( ThisTransVar, '~', 7 )
		
		IF MultiStep > 0 THEN
			WOBoxCnt = COUNT(XLATE('WO_STEP',ThisWOStepKey,6,'X'),@VM)		;* 5/21/2005 - JCH - Added for Order Entry/Vision upgrade
		END ELSE
			
			EXTRACT_SI_KEYS( 'RDS', 'WO', ThisWO, RDSsInWO )				;* Original Code
			
			WOBoxCnt = FIELDCOUNT( RDSsInWO, @VM )							;* Original Code
		END
		
		* First check thickness
		
		PrintThickness = false$
		IF ( ThisRunOrdNum = 1 ) AND ( ThickFirst )			THEN PrintThickness = true$
		IF ( ThisRunOrdNum = WOBoxCnt ) AND ( ThickLast )	THEN PrintThickness = true$
		
		IF ThickFreq THEN
			* Need to check run order and see if it needs to be printed
			IF ThickFreq = 1 THEN
				PrintThickness = true$
			END ELSE
				* Generate @FM delim of runs that should print
				RoPrintFlag = str( @FM, WOBoxCnt-1 )
				FOR J  = 1 TO WOBoxCnt step ThickFreq
					RoPrintFlag<J> = 1
				NEXT J 
				IF ( RoPrintFlag<ThisRunOrdNum> = 1 )		THEN PrintThickness = true$            
			END 
		END
		
		IF PrintThickness THEN
			PSNRec    = XLATE( 'PROD_SPEC', PSNIds<I>, '', 'X' )
			SpecSub   = PSNRec<prod_spec_spec_substrate$>
			
			TOrient = SpecSub<1,QSSubOrientation$>
			convert '<' TO '' in TOrient
			convert '>' TO '' in TOrient
			Orient = TOrient
			
			ThickPrintVar<I> = ThickTool:'~':ThickType:'~':Orient:'~':ThickRecipe
		END ELSE
			ThickPrintVar<I> = ''
		END
		
		* Now check resistivity
		
		PrintResistivity = false$
		IF ( ThisRunOrdNum = 1 ) and ( ResFirst )			THEN PrintResistivity = true$
		IF ( ThisRunOrdNum = WOBoxCnt ) and ( ResLast )		THEN PrintResistivity = true$
		
		IF ResFreq THEN
			* NEED TO CHECK RUN ORDER AND SEE IF IT NEEDS TO BE PRINTED
			IF ResFreq = 1 THEN
				PrintResistivity = true$
			END ELSE
				* Generate @FM delim of runs that should print
				RoPrintFlag = str( @FM, WOBoxCnt-1 )
				FOR J  = 1 TO WOBoxCnt step ResFreq
					RoPrintFlag<J> = 1
				NEXT J 
				IF ( RoPrintFlag<ThisRunOrdNum> = 1 )		THEN PrintResistivity = true$
			END 
		END
		
		IF PrintResistivity THEN
			PSNRec    = XLATE( 'PROD_SPEC', PSNIds<I>, '', 'X' )
			SpecSub   = PSNRec<prod_spec_spec_substrate$>				;******* Moved to EPI_PART
			
			TOrient = SpecSub<1,QSSubOrientation$>
			convert '<' TO '' in TOrient
			convert '>' TO '' in TOrient
			Orient = TOrient
			
			ResPrintVar<I> = ResTool:'~':ResType:'~':Orient:'~':ResRecipe
		END ELSE
			ResPrintVar<I> = ''
		END
		
		PrintSRP = false$
		SRPType  = ''
		IF SRPFlag<I> THEN
			* We know that SRP is one of the tools
			
			IF PrintThickness THEN
				IF ThickTool = 'SRP' THEN
					PrintSRP = true$
					SRPType  = ThickType
				END
			END
			
			IF PrintResistivity THEN
				IF ResTool = 'SRP' THEN
					PrintSRP = true$
					SRPType  = ResType
				END
			END
			
			
			IF NOT(PrintSRP) THEN
				
				* Now need to check concentration
				
				IF ConTool = 'SRP' THEN
					IF ( ThisRunOrdNum = 1 ) and ( ConFirst )		THEN PrintSRP = true$
					IF ( ThisRunOrdNum = WOBoxCnt ) and ( ConLast )	THEN PrintSRP = true$
					
					IF ConFreq THEN
						* Need to check run order and see if it needs to be printed
						IF ConFreq = 1 THEN
							PrintSRP = true$
						END ELSE
							* Generate fm delim of runs that should print
							RoPrintFlag = str( @FM, WOBoxCnt-1 )
							FOR J  = 1 TO WOBoxCnt step ConFreq
								RoPrintFlag<J> = 1
							NEXT J 
							IF ( RoPrintFlag<ThisRunOrdNum> = 1 )	THEN PrintSRP = true$
						END 
					END
				END
				IF PrintSRP THEN SRPType = ConType   
			END
			
			
			IF NOT(PrintSRP) THEN
				
				* Now need to check stress
				
				IF StressTool = 'SRP' THEN
					IF ( ThisRunOrdNum = 1 ) AND ( StressFirst ) 		THEN PrintSRP = true$
					IF ( ThisRunOrdNum = WOBoxCnt ) AND ( StressLast )	THEN PrintSRP = true$
					
					IF StressFreq THEN
						* Need to check run order and see if it needs to be printed
						IF StressFreq = 1 THEN
							PrintSRP = true$
						END ELSE
							* Generate @FM delim of runs that should print
							RoPrintFlag = str( @FM, WOBoxCnt-1 )
							FOR J  = 1 TO WOBoxCnt step StressFreq
								RoPrintFlag<J> = 1
							NEXT J 
							IF ( RoPrintFlag<ThisRunOrdNum> = 1 )		THEN PrintSRP = true$
						END
					END
				END
				IF PrintSRP THEN  SRPType = StressType
			END
			
			IF NOT(PrintSRP) THEN
				* Now need to check transition
				IF TransTool = 'SRP' THEN
					IF ( ThisRunOrdNum = 1 ) AND ( TransFirst )			THEN PrintSRP = true$
					IF ( ThisRunOrdNum = WOBoxCnt ) AND ( TransLast )	THEN PrintSRP = true$
					
					IF TransFreq THEN
						* Need to check run order and see if it needs to be printed
						IF TransFreq = 1 THEN
							PrintSRP = true$
						END ELSE
							* Generate fm delim of runs that should print
							RoPrintFlag = str( @FM, WOBoxCnt-1 )
							FOR J  = 1 TO WOBoxCnt step TransFreq
								RoPrintFlag<J> = 1
							NEXT J 
							IF ( ROPrintFlag<ThisRunOrdNum> = 1 )		THEN PrintSRP = true$
						END
						IF PrintSRP THEN SRPType = TransType
					END
				END
			END
			
			IF PrintSRP THEN
				SRPPrintVar<I> = true$
				SRPTypePrintVar<I> = SRPType
			END ELSE
				SRPPrintVar<I> = false$
				SRPTypePrintVar<I> = ''
			END
			
		END ELSE
			SRPPrintVar<I> = false$
			SRPTypePrintVar<I> = ''
		END
	NEXT I
	
	* Got all data now we can print
	
	FOR I = 1 TO IdCnt
		PrintCustName        = CustName<I>
		
		IF MultiStep > 0 THEN
			WONo = WO<I>:'.':MultiStep						;* 5/21/2005 - JCH - Added for Order Entry/Vision upgrade
			WONo = WOStepKeys<I>
			CONVERT '*' TO '.' IN WONo
		END ELSE
			WoNo = WO<I>
		END
		
		PrintWO					= WoNo		 		;* 5/21/2005 - JCH - Changed for Order Entry/Vision upgrade
		PrintPSNNo				= PSNIds<I>			;* 6/10/2005 - JCH - Added per manufacturing manager request 
		PrintLotNum				= LotNum<I>
		PrintRecipeInfo			= RecipeInfo<I>
		PrintSpecType			= SpecType<I>             
		PrintRONum				= RONum<I>
		PrintRdsId				= RdsIds<I>
		PrintThickPrintVar		= ThickPrintVar<I>
		PrintResPrintVar		= ResPrintVar<I>
		PrintMultiLayVar		= MultiLayVar<I>
		PrintSRPPrintVar		= SRPPrintVar<I>
		PrintSRPTypePrintVar	= SRPTypePrintVar<I>
		PrintQty				= Qtys<I>
		ThickCnt = FIELDCOUNT( ThickTarget<I>, @VM )
		PrintThickTargets = ''
		FOR J  = 1 TO ThickCnt
			PrintThickTargets<1,J> = ThickTarget<i,j>:ThickUnit<i,j>
		NEXT J 
		
		ResCnt = FIELDCOUNT( ResTarget<I>, @VM )
		PrintResTargets = ''
		FOR J  = 1 TO ResCnt
			IF ResTarget<I,J>[1,1] = '.' THEN
				TargetVal = '0':ResTarget<I,J>
			END ELSE
				TargetVal = ResTarget<I,J>
			END
			PrintResTargets<1,J> = TargetVal:ResUnit<I,J>
		NEXT J 
		
		PrintPO					= PO<I>
		PrintPartNum			= PartNum<I>:' ':CustPNDescs<I>
		PrintPartNo				= PartNum<I>
		PrintSubPartNum			= SubPartNum<I>
		
		SubSupplier	= obj_Vendor_Code('SemiToEpi',WOMatRec<WO_MAT_SUB_VEND_CD$>)
		
		VendCd = XLATE('COMPANY',CustNo,COMPANY_VEND_CD$,'X')
		PrintCompany = XLATE('COMPANY', CustNo, COMPANY_CO_NAME$, 'X')
		
		IF VendCd NE '' THEN
			SubSupplier = VendCd	;* Substrate supplier code found in the EPI_PART window. 12/9/2011 for cust 7067
		END
		
		PrintSuppCd				= SubSupplier
		PrintDopant				= Dopant<I>
		PrintShipBagReq			= ShipBagReq			;* Changed to single value ShipBagReq  9/27/2012 JCH
		PrintReqShipDate		= ReqShipDate<I>
		PrintSubOxide			= SubOxide<I>
		PrintReactType			= ReactTypes<I>
		PrintSubPreClean		= SubPreCleans<I>
		PrintSubPostClean		= SubPostCleans<I>
		PrintPreAkrionRecipe	= PreAkrionRecipes<I>
		PrintPostAkrionRecipe	= PostAkrionRecipes<I>
		
		APreRec  = ''
		APostRec = ''
		IF ( PreAkrionRecipes<I> <> '' ) THEN
			APreRec = ' ':PreAkrionRecipes<I>:' '
			SubOxide<I> = 'No' ;* IF AKRION THEN NO OXIDE STRIP
		END
		
		IF ( PostAkrionRecipes<I> <> '' ) THEN
			APostRec = ' ':PostAkrionRecipes<I>
		END
		
		swap '~' with fmt( ' ', 'L#2' ) in PrintThickPrintVar
		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 '~' with fmt( ' ', 'L#2' ) in PrintResPrintVar
		swap 'Ã¦m' with 'um' in PrintResTargets
		swap 'Ãª-cm' with 'ohm.cm' in PrintResTargets
		swap 'Ãª/Ãœ' with 'ohm/sq' in PrintResTargets
		swap 'Â' with 'A' in PrintResTargets
		
		//only print cheat sheet label on cassette #1
		IF CassNo EQ 1 then
			GOSUB PrintCheatSheetLabel
		end
		
		GOSUB PrintLabel
		
	NEXT I
	
RETURN


* * * * * * *
PrintLabel:
* * * * * * *
	* Standard RDS Label print method
	IF PrintSpecType	EQ 'Production'		THEN PrintSpecType	= 'Prod'
	IF PrintSpecType	EQ 'Pre-Production' THEN PrintSpecType	= 'Pre'

	EpiPartRec			= XLATE('EPI_PART',EpiPartNo,'','X')
	IsExportControl		= EpiPartRec<EPI_PART_EXPORT_CONTROL$>
	CustEpiPartRec		= XLATE('CUST_EPI_PART',CustNo:'*':EpiPartNo,'','X')
	CustEpiPartSpecNo	= CustEpiPartRec<CUST_EPI_PART_SPEC_NO$>[-1,'B':@VM]	;* Last (current) Customer Spec Number
	PrintPSN			= XLATE('RDS',PrintRDSId,'PROD_SPEC_ID', 'X')
	PrintRecipe			= ''
	PSStageKey			= PrintPSN:'*QA'
	PrintRecipe			= XLATE('PRS_STAGE',PSStageKey,'MET_RECIPE','X')
	PrintQARecipe		= FIELD(PrintRecipe, @VM, 1)
	PrintCompany		= PrintCompany[1,32]

//looping instead of using ^PQ2 since I have to set sequential key in 2D barcode

	Str	= ''
For cnt = 1 to 2
	Str := '^XA'
	Str := '^LH0,0'
	Str := '^PR1'		;* Print speed 2 inches per second
	Str := '^LL406'		;* Label length @203 dpi
	Str := '^PW900'
	Str := '^MD0'		;* Media darkness							
	Str := '^MMT'		;* Media mode t=tear off mode
	*Str := '^PQ2'		;* Print 2 labels for each pass through here
	
	****** First Line, Cust, WO and RO
	Str := '^FO25,25^AC,18^FDCust: ^FS':CRLF$
	Str := '^FO95,14^A045,35^FD':PrintCompany:'^FS':CRLF$
	Str	:= '^FO570,25^AC18^FDWO: ^FS':CRLF$
	Str := '^FO610,14^A045,35^FD':PrintWO:'^FS':CRLF$
	Str	:= '^FO730,25^AC18^FDRO: ^FS':CRLF$
	Str	:= '^FO770,14^A045,35^FD':PrintRONum:'^FS':CRLF$
	
	****** Second Line, Cust Spec, PSN and Type
	Str	:= '^FO25,75^AC18^FD(P)Cust Spec: ^FS':CRLF$
	Str	:= '^FO185,65^A045,35^FD':CustEpiPartSpecNo:'^FS':CRLF$
	Str	:= '^FO25,95^BY2,2.0^B3,,50,N^FDP':CustEpiPartSpecNo:'^FS':CRLF$
	Str	:= '^FO640,75^AC18^FDPSN:^FS':CRLF$
	Str	:= '^FO690,65^A045,35^FD':PrintPSN:'^FS':CRLF$
	Str	:= '^FO630,125^AC18^FDType:^FS':CRLF$
	Str	:= '^FO690,115^A045,30^FD':PrintSpecType:'^FS':CRLF$
	
	****** Third Line, Sub Lot, Qty and RDS
	Str	:= '^FO25,175^AC18^FD(2T)Sub Lot:^FS':CRLF$
	Str	:= '^FO175,165^A045,35^FD':PrintLotNum:'^FS':CRLF$
	Str	:= '^FO25,195^BY1,3.0^B3,,50,N^FD2T':PrintLotNum:'^FS':CRLF$
	Str	:= '^FO400,175^AC18^FD(Q)Qty:^FS':CRLF$
	Str	:= '^FO500,165^A045,35^FD':PrintQty:'^FS':CRLF$
	Str	:= '^FO400,195^B3,,50,N^FDQ':PrintQty:'^FS':CRLF$
	Str	:= '^FO590,175^AC18^FD(1T)RDS: ^FS':CRLF$
	Str	:= '^FO690,165^A045,35^FD':PrintRDSId:'^FS':CRLF$
	Str	:= '^FO630,195^B3,,50,N^FD1T':PrintRDSId:'^FS':CRLF$
	
	****** Fourth Line, SubPN, Vendor and QA Metrology recipe
	Str	:= '^FO25,275^AC18^FD(S)Sub PN:^FS':CRLF$
	Str	:= '^FO145,265^A045,35^FD':PrintSubPartNum:'^FS':CRLF$
	Str	:= '^FO25,295^B3,,50,N^FDS':PrintSubPartNum:'^FS':CRLF$
	Str	:= '^FO400,275^AC18^FD(1V)Vend:^FS':CRLF$
	Str	:= '^FO510,265^A045,35^FD':PrintSuppCd:'^FS':CRLF$
	Str	:= '^FO400,295^B3,,50,N^FD1V':PrintSuppCd:'^FS':CRLF$
	Str	:= '^FO590,275^AC18^FD':PrintQARecipe:'^FS':CRLF$
	
	****** Fifth Line, Motto and Data Matrix barcode
	Str	:= '^FO25,370^A045,28':CRLF$
	Str	:= "^FDWe do what we promise. That's quality made by Infineon.^FS":CRLF$
	Str	:= '^FO725,320^CI28':CRLF$
	Str	:= '^BXN,2,200^FDP':CustEpiPartSpecNo:'|S':PrintSubPartNum:'|1T':PrintRDSId:'|2T':PrintLotNum:'|':PrintPSN:'|Q':PrintQty:'|1V':PrintSuppCd:'|SEQ':cnt:'^FS':CRLF$
	
	****** End the print job (ZPL script)
	Str:= '^XZ'
Next

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(RdsIds,@FM) + (RdsIds NE '')
	ShelfCnt = INT(RDSCnt/28) + (MOD(RDSCnt,28) NE 0)		;* Come back TO this later JCH 7/27/2005
	
	NewUniqueWOs = ''
	NewCustNos  = ''
	UWOCnt = fieldcount( UniqueWOs, @VM )
	FOR I = 1 TO UWOCnt
		NewUniqueWOs<1,-1> = UniqueWOs<1,I>:@VM:UniqueWOs<1,I>
		NewCustNos<1,-1> = CustNos<1,I>:@VM:CustNos<1,I>
	NEXT I
	
	TRANSFER NewUniqueWOs TO UniqueWOs
	TRANSFER NewCustNos to CustNos
	UWOCnt += UWOCnt
	
	* So we print two sets of labels           	         

	FOR I = 1 TO UWOCnt step 2
		PrintUniqueWO	= UniqueWOs<1,i>
		PrintSAPOrder	= XLATE('WO_LOG', WO, 'PROD_ORD_NO', 'X')			; * Xlate WO # into SAP Production Order #  dkk 6/18/15
		CustNo			= CustNos<1,i>
		GOSUB PrintWOLabel
		
		PrintUniqueWO = UniqueWOs<1,i+1>									; * Prints a 2nd WO label
		CustNo        = CustNos<1,i+1>
		GOSUB PrintWOLabel
		
	NEXT I 
	
RETURN


* * * * * * *
PrintWOLabel:
* * * * * * *
	
	Str = '^XA'			;* start ZPL script
	Str:= '^CFD'		;* change default font to D
	Str:= '^LH0,0'		;* label home
	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':PrintUniqueWO:'^FS':CRLF$	 			
		
	END ELSE
		Str:= '^FO70,30^A0220,210^FD':PrintUniqueWO:'^FS':CRLF$				
		
	END
	
	CustName		= XLATE( 'COMPANY', CustNo, 'ABBREV_OR_CO_NAME', 'X' )
	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


* * * * *
PrintCheatSheetLabel:
* * * * *

	//DPC 9/1/2020 - label printed with WO labels (first cassette) gives
	//operators ability to see specs on label that doesn't leave FAB
	PsnRec		= XLATE('PROD_SPEC', PSNIDs, '', 'X')
	
	SpecEpi		= PsnRec<prod_spec_spec_epi$>
	SpecSub		= PsnRec<PROD_SPEC_SPEC_SUBSTRATE$>
	
	ThkSmile	= PsnRec<PROD_SPEC_THICK_SMILE_REQ$>
	ThkShift	= Field(PsnRec, @FM, PROD_SPEC_THICK_LIMIT_SHIFT$)
	
	ResShift	= Field(PsnRec, @FM, PROD_SPEC_RES_LIMIT_SHIFT$)
	
	SSRecipe	= XLATE('PRS_STAGE', PSNIDs:'*LWI', 5, 'X')
	PCRecipe	= XLATE('PRS_STAGE', PSNIDs, 'POST_CLEAN_SURFSCAN_RECIPE', 'X')
	CustPart	= PsnRec<PROD_SPEC_CUST_PART_NO$>
	WaferSize	= XLATE('EPI_PART', CustPart, EPI_PART_SUB_WAFER_SIZE$, 'X')
	*Field(SpecSub, @VM, QSSubWafersize$)

convert char(248) to @fm in SpecEpi ;* char(248) is used to separate layers
layerCount = fieldcount( SpecEpi, @fm )
layerInfo =  SpecEpi<layerCount>
//if this is just 1 layer, we're returning that info, if 3 layers, we're returning layer 3 (combo)
 	
 	ThkData		= Field(layerInfo, @VM, QSEpiThickMeasure$)
	ResData		= Field(layerInfo, @VM, QSEpiResMeasure$)
	ConData		= Field(layerInfo, @VM, QSEpiConcMeasure$)
	CResData	= Field(layerInfo, @VM, QSEpiCresMeasure$)
	
 	ThkMin		= OCONV(Field(layerInfo, @VM, QSEpiMinThick$), 'MD3')
 	ThkMax		= OCONV(Field(layerInfo, @VM, QSEpiMaxThick$), 'MD3')
 	ThkTarg		= ''
 	If ThkMin NE '' Then ThkTarg = oConv(iconv((ThkMin+ThkMax)/2, 'MD3'), 'MD3')

 	ResMin		= OCONV(Field(layerInfo, @VM, QSEpiResMinThick$), 'MD3')
 	ResMax		= OCONV(Field(layerInfo, @VM, QSEpiResMaxThick$), 'MD3')
 	ResTarg		= ''
 	If ResMin NE '' Then ResTarg = oConv(iconv((ResMin+ResMax)/2, 'MD3'), 'MD3')
 	
 	ConMin		= OCONV(Field(layerInfo, @VM, QSEpiConcMinThick$), 'MD3')
 	ConMax		= OCONV(Field(layerInfo, @VM, QSEpiConcMaxThick$), 'MD3')
 	ConTarg		= ''
 	If ConMin NE '' Then ConTarg = oConv(iconv((ConMin+ConMax)/2, 'MD3'), 'MD3')

 	CResMin		= OCONV(Field(layerInfo, @VM, QSEpiCresMin$), 'MD3')
 	CResMax		= OCONV(Field(layerInfo, @VM, QSEpiCresMax$), 'MD3')
 	CResTarg	= ''
 	If CResMin NE '' Then CResTarg = oConv(iconv((CResMin+CResMax)/2, 'MD3'), 'MD3')

	ThkTool		= Field(ThkData, '~', PS$TOOL)
	ThkType		= Field(ThkData, '~', PS$TYPE)
	ThkRecipe	= Field(ThkData, '~', PS$RECIPE)
	ThkFreq		= Field(ThkData, '~', PS$FREQ)
	ThkPattern	= Field(ThkData, '~', PS$PATTERN)
 	
 	ResTool		= Field(ResData, '~', PS$TOOL)
	ResType		= Field(ResData, '~', PS$TYPE)
	ResRecipe	= Field(ResData, '~', PS$RECIPE)
	ResFreq		= Field(ResData, '~', PS$FREQ)
	ResPattern	= Field(ResData, '~', PS$PATTERN)
	
 	ConTool		= Field(ConData, '~', PS$TOOL)
	ConType		= Field(ConData, '~', PS$TYPE)
	ConRecipe	= Field(ConData, '~', PS$RECIPE)
	ConFreq		= Field(ConData, '~', PS$FREQ)
	ConPattern	= Field(ConData, '~', PS$PATTERN)
		
 	CResTool	= Field(CResData, '~', PS$TOOL)
	CResType	= Field(CResData, '~', PS$TYPE)
	CResRecipe	= Field(CResData, '~', PS$RECIPE)
	CResFreq	= Field(CResData, '~', PS$FREQ)
	CResPattern	= Field(CResData, '~', PS$PATTERN)

	IF ThkMin		EQ '' THEN ThkMin		= '--'
	IF ThkMax		EQ '' THEN ThkMax		= '--'
	IF ThkTarg		EQ '' THEN ThkTarg		= '--'
	IF ThkTool		EQ '' THEN ThkTool		= '--'
	IF ThkType		EQ '' THEN ThkType		= '--'
	IF ThkRecipe	EQ '' THEN ThkRecipe	= '--'
	IF ThkPattern	EQ '' THEN ThkPattern	= '--'
	IF ThkFreq		EQ '' THEN ThkFreq		= '--'

	IF ResMin		EQ '' THEN ResMin		= '--'
	IF ResMax		EQ '' THEN ResMax		= '--'
	IF ResTarg		EQ '' THEN ResTarg		= '--'
	IF ResTool		EQ '' THEN ResTool		= '--'
	IF ResType		EQ '' THEN ResType		= '--'
	IF ResRecipe	EQ '' THEN ResRecipe	= '--'
	IF ResPattern	EQ '' THEN ResPattern	= '--'
	IF ResFreq		EQ '' THEN ResFreq		= '--'

	IF ConMin		EQ '' THEN ConMin		= '--'
	IF ConMax		EQ '' THEN ConMax		= '--'
	IF ConTarg		EQ '' THEN ConTarg		= '--'
	IF ConTool		EQ '' THEN ConTool		= '--'
	IF ConType		EQ '' THEN ConType		= '--'
	IF ConRecipe	EQ '' THEN ConRecipe	= '--'
	IF ConPattern	EQ '' THEN ConPattern	= '--'
	IF ConFreq		EQ '' THEN ConFreq		= '--'

	IF CResMin		EQ '' THEN CResMin		= '--'
	IF CResMax		EQ '' THEN CResMax		= '--'
	IF CResTarg		EQ '' THEN CResTarg		= '--'
	IF CResTool		EQ '' THEN CResTool		= '--'
	IF CResType		EQ '' THEN CResType		= '--'
	IF CResRecipe	EQ '' THEN CResRecipe	= '--'
	IF CResPattern	EQ '' THEN CResPattern	= '--'
	IF CResFreq		EQ '' THEN CResFreq		= '--'
 	
 	Swap @VM with ' / ' in SSRecipe
 	IF PCRecipe EQ '' Then PCRecipe = '--'
 	
 	If ThkSmile EQ '' OR ThkSmile EQ '0' then
		ThkSmile = 'N'
	end else
		ThkSmile = 'Y'
	end
	
	If ThkShift EQ '' OR ThkShift EQ '0' then
		ThkShift = 'N'
	end else
		ThkShift = 'Y'
	end
	
	If ResShift EQ '' OR ResShift EQ '0' then
		ResShift = 'N'
	end else
		ResShift = 'Y'
	end

	if Len(ThkMin) > 6 then
		ThkMin = ThkMin[1,6]
	end
	if Len(ThkMax) > 6 then
		ThkMax = ThkMax[1,6]
	end	
	if Len(ThkTarg) > 6 then
		ThkTarg = ThkTarg[1,6]
	end
	
	if Len(ResMin) > 6 then
		ResMin = ResMin[1,6]
	end
	if Len(ResMax) > 6 then
		ResMax = ResMax[1,6]
	end	
	if Len(ResTarg) > 6 then
		ResTarg = ResTarg[1,6]
	end
	
	if Len(ConMin) > 6 then
		ConMin = ConMin[1,6]
	end
	if Len(ConMax) > 6 then
		ConMax = ConMax[1,6]
	end	
	if Len(ConTarg) > 6 then
		ConTarg = ConTarg[1,6]
	end	
	
	
	if Len(CResMin) > 6 then
		CResMin = CResMin[1,6]
	end
	if Len(CResMax) > 6 then
		CResMax = CResMax[1,6]
	end	
	if Len(CResTarg) > 6 then
		CResTarg = CResTarg[1,6]
	end	
	
 	****** Begin ZPL
 	Str = '^XA'
 	Str := '^LH10,0'
 	Str := '^PR2'		;* Print speed 2 inches per second
 	Str := '^LL406'		;* Label length @203 dpi
 	Str := '^PW900'
 	Str := '^MD0'		;* Media darkness							
 	Str := '^MMT'		;* Media mode t=tear off mode
 	
 	****** 1st/2nd Line 
 	Str := '^FO30,20^A0,,40^FDWO ':PrintWO:'^FS'
	Str := '^FO590,10^A050,30^FDPSN ':PrintPSNNo:'^FS'
	Str := '^FO555,40^A050,30^FDDopant ':PrintDopant:'^FS'	
 	
 	****** 3rd Line - headers
 	Str := '^FO85,100^A050,23^FDMin^FS'
	Str := '^FO145,100^A050,23^FDTarg^FS'
	Str := '^FO210,100^A050,23^FDMax^FS'
	Str := '^FO280,100^A050,23^FDTool^FS'
	Str := '^FO330,100^A050,23^FDType^FS'
	Str := '^FO470,100^A050,23^FDRecipe^FS'
	Str := '^FO600,100^A050,23^FDPattern^FS'
	Str := '^FO740,100^A050,23^FDFreq^FS'
 	
	****** 4th Line - Thickness (Thk)
 	Str := '^FO70,130^GB720,0,3^FS'
	Str := '^FO70,130^GB0,160,3^FS'
 	Str := '^FO10,140^A050,23^FDThk:^FS'
 	Str := '^FO80,140^A050,23^FD':ThkMin:'^FS'
 	Str := '^FO145,140^A050,23^FD':ThkTarg:'^FS'
 	Str := '^FO210,140^A050,23^FD':ThkMax:'^FS'
 	Str := '^FO280,140^A050,23^FD':ThkTool[1,5]:'^FS'
 	Str := '^FO330,140^A050,23^FD':ThkType[1,11]:'^FS'
 	Str := '^FO470,140^A050,23^FD':ThkRecipe[1,11]:'^FS'
 	Str := '^FO600,140^A050,23^FD':ThkPattern[1,11]:'^FS'
 	Str := '^FO750,140^A050,23^FD':ThkFreq:'^FS'

	****** 5th Line - Resistivity (Res)
 	Str := '^FO10,170^GB780,0,3^FS'
 	Str := '^FO10,180^A050,23^FDRes:^FS'
 	Str := '^FO80,180^A050,23^FD':ResMin:'^FS'
 	Str := '^FO145,180^A050,23^FD':ResTarg:'^FS'
 	Str := '^FO210,180^A050,23^FD':ResMax:'^FS'
 	Str := '^FO280,180^A050,23^FD':ResTool[1,5]:'^FS'
 	Str := '^FO330,180^A050,23^FD':ResType[1,11]:'^FS'
 	Str := '^FO470,180^A050,23^FD':ResRecipe[1,11]:'^FS'
 	Str := '^FO600,180^A050,23^FD':ResPattern[1,11]:'^FS'
 	Str := '^FO750,180^A050,23^FD':ResFreq:'^FS'

 	****** 6th Line - Contact (Con)
 	Str := '^FX***LINE 4'
 	Str := '^FO10,210^GB780,0,3^FS'
 	Str := '^FO10,220^A050,23^FDCon:^FS'
 	Str := '^FO80,220^A050,23^FD':ConMin:'^FS'
 	Str := '^FO145,220^A050,23^FD':ConTarg:'^FS'
 	Str := '^FO210,220^A050,23^FD':ConMax:'^FS'
 	Str := '^FO280,220^A050,23^FD':ConTool[1,5]:'^FS'
 	Str := '^FO330,220^A050,23^FD':ConType[1,11]:'^FS'
 	Str := '^FO470,220^A050,23^FD':ConRecipe[1,11]:'^FS'
 	Str := '^FO600,220^A050,23^FD':ConPattern[1,11]:'^FS'
 	Str := '^FO750,220^A050,23^FD':ConFreq:'^FS'
 	
 	****** 7th Line - Contact Resistance (CRes)
 	Str := '^FO10,250^GB780,0,3^FS'
 	Str := '^FO10,260^A050,23^FDCRes:^FS'
 	Str := '^FO80,260^A050,23^FD':CResMin:'^FS'
 	Str := '^FO145,260^A050,23^FD':CResTarg:'^FS'
 	Str := '^FO210,260^A050,23^FD':CResMax:'^FS'
 	Str := '^FO280,260^A050,23^FD':CResTool[1,5]:'^FS'
 	Str := '^FO330,260^A050,23^FD':CResType[1,11]:'^FS'
 	Str := '^FO470,260^A050,23^FD':CResRecipe[1,11]:'^FS'
 	Str := '^FO600,260^A050,23^FD':CResPattern[1,11]:'^FS'
 	Str := '^FO750,260^A050,23^FD':CResFreq:'^FS'
 	
 	Str := '^FO10,290^GB780,0,3^FS'
 	
 	****** 8th Line - Special Instructions
	Str := '^FO10,310^A050,23^FDSurfScan: ':SSRecipe:'^FS'
	Str := '^FO10,340^A050,23^FDPostClean: ':PCRecipe:'^FS'
	Str := '^FO10,370^A050,23^FDWafer Size: ':WaferSize:'^FS'
	Str := '^FO560,310^A050,23^FDSmile Required: ':ThkSmile:'^FS'
	Str := '^FO560,340^A050,23^FDSPC Thk Shift: ':ThkShift:'^FS'
	Str := '^FO560,370^A050,23^FDSPC Res Shift: ':ResShift:'^FS'

 	Str:= '^XZ'
	****** End ZPL

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

