COMPILE SUBROUTINE Print_WMI_Labels(WONo,WOStep)
#pragma precomp SRP_PreCompiler

$INSERT LOGICAL
$INSERT MSG_EQUATES
$INSERT OIPRINT_EQUATES
$INSERT PROD_SPEC_EQUATES
$INSERT POPUP_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 WM_IN_EQUATES
$INSERT CUST_EPI_PART_EQUATES
$insert UNIT_EQUATES

DECLARE FUNCTION Msg,  Get_Printer, Set_Printer, Utility, obj_Install, Printer_Select, FieldCount, Popup
DECLARE FUNCTION MemberOF, Direct_Print, Environment_Services
DECLARE SUBROUTINE Btree.Extract, ErrMsg, SRP_Set_Clipboard

* 5/18/2006 - Cloned from Print_Cass_Labels

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

Main:

	IF NOT(ASSIGNED(WONo))	THEN RETURN
	IF WONo = '' 			THEN RETURN

	IF NOT(ASSIGNED(WOStep)) THEN WOStep = 1

	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 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 GE 0 THEN 

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

		OPEN 'DICT.WM_IN' TO DictVar ELSE
			ErrMsg('Unable to open DICT.WM_IN in PRINT_WMI_LABELS for Btree.Extract.')
			RETURN
		END

		WMInKeys = XLATE('WO_STEP',WONo:'*':WOStep,WO_STEP_WM_IN_KEYS$,'X')

		IF WMInKeys = '' THEN RETURN

		TypeOver              = ''
		TypeOver<PDISPLAY$>   = WMInKeys
		TypeOver<PTITLE$>     = 'WM_IN - Inbound Cassettes'
		TypeOver<PSHOWGAUGE$> = True$

		WMInKeys = Popup(@WINDOW,TypeOver,'PRINT_WMI_LABELS')
		CONVERT '.' TO '*' IN WMInKeys

		IF WMInKeys = '' THEN RETURN

		Void = Utility( 'CURSOR', 'H' )

		WOStepKeys = XLATE('WO_LOG',WONo,WO_LOG_WO_STEP_KEY$,'X')

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

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

		ReqShipDate	= OCONV(WORec<WO_LOG_PROMISE_SHIP_DT$>,'D2/')

		CustNo		= WORec<WO_LOG_CUST_NO$>
		CustName	= XLATE('COMPANY',CustNo,'ABBREV_OR_CO_NAME','X')
		Captive		= XLATE('COMPANY',CustNo,'CAPTIVE','X')
		PONo		= WORec<WO_LOG_CUST_PO_NO$>

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

		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

		EpiPartNo         = WORec<WO_LOG_EPI_PART_NO$>
		CustEpiPartRec    = XLATE('CUST_EPI_PART',CustNo:'*':EpiPartNo,'','X')
		ShipBagReq        = CustEpiPartRec<CUST_EPI_PART_SHIP_BAG_REQ$>
		PreSurfscan       = PSRec<PROD_SPEC_PRE_SURFSCAN$>
		FirstSurfscan     = PSRec<PROD_SPEC_FIRST_SURFSCAN$>
		PostCleanSurfScan = PSRec<PROD_SPEC_POST_CLEAN_SURFSCAN$>
		SubPreClean       = XLATE( 'PROD_SPEC', PSNo, 'SUB_PRE_CLEAN', 'X' )
		SubPostClean      = XLATE( 'PROD_SPEC', PSNo, 'SUB_POST_CLEAN', 'X' )
		PreCleanTool      = SubPreClean					;* Temporary for 2x4 -> 4x4 conversion
		PostCleanTool     = SubPostClean
		PreAkrionRecipe   = XLATE( 'PROD_SPEC', PSNo, 'PRE_AKRION_RECIPE', 'X' )   
		PostAkrionRecipe  = XLATE( 'PROD_SPEC', PSNo, 'POST_AKRION_RECIPE', 'X' )
		RecipeNo          = XLATE( 'PROD_SPEC', PSNo, 'RECIPE_NO_L1', 'X' )
		RecipeName        = XLATE( 'PROD_SPEC', PSNo, 'RECIPE_NAME_L1', 'X' )
		SpecType          = OCONV( XLATE( 'PROD_SPEC', PSNo, 'SPEC_TYPE', 'X' ), '[SPEC_TYPE_CONV]' )
		SubOxide          = OCONV( XLATE( 'PROD_SPEC', PSNo, 'SUB_OXIDE_STRIP', 'X' ), 'B' )
		ThickTarget       = OCONV( XLATE( 'PROD_SPEC', PSNo, 'THICK_TARGET_ALL', 'X' ), 'MD3' )
		ResTarget         = OCONV( XLATE( 'PROD_SPEC', PSNo, 'RES_TARGET_ALL', 'X' ), 'MD3' )
		ThickUnit         = XLATE( 'PROD_SPEC', PSNo, 'THICK_UNITS_ALL', 'X' )
		ResUnit           = XLATE( 'PROD_SPEC', PSNo , 'RES_UNITS_ALL', 'X' )
		Dopant            = XLATE( 'PROD_SPEC', PSNo, 'DOPANT_L1', 'X' )
		RecipeNo          = XLATE( 'PROD_SPEC', PSNo, 'RECIPE_NO', 'X' )	
		RecipeInfo        = XLATE( 'RECIPE', RecipeNo, 'RECIPE_NAME_NO', 'X' )
		CleaningReqs      = ''
		ThickCnt          = FIELDCOUNT( ThickTarget<1>, @VM )
		PrintThickTargets = ''
		FOR J  = 1 TO ThickCnt
			PrintThickTargets<1,J> = ThickTarget<1,J>:ThickUnit<1,J>
		NEXT J 

		ResCnt = FIELDCOUNT( ResTarget<1>, @VM )
		PrintResTargets = ''
		FOR J  = 1 TO ResCnt
			IF ResTarget<1,J>[1,1] = '.' THEN
				TargetVal = '0':ResTarget<1,J>
			END ELSE
				TargetVal = ResTarget<1,J>
			END
			PrintResTargets<1,J> = TargetVal:ResUnit<1,J>
		NEXT J 

		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:':SubPreClean:APreRec:' Post:':SubPostClean:APostRec )

		swap UNIT_MICROMETER$ with 'um' in PrintThickTargets
		swap UNIT_OHM_CM$     with 'ohm.cm' in PrintThickTargets
		swap UNIT_OHM_PER_SQ$ with 'ohm/sq' in PrintThickTargets
		swap UNIT_A$ with 'A' in PrintThickTargets  

		swap UNIT_MICROMETER$ with 'um' in PrintResTargets
		swap UNIT_OHM_CM$     with 'ohm.cm' in PrintResTargets
		swap UNIT_OHM_PER_SQ$ with 'ohm/sq' in PrintResTargets
		swap UNIT_A$ with 'A' in PrintResTargets

		WMIBoxCnt = COUNT( WMInKeys, @VM ) + (WMInKeys NE '')

		GOSUB PrintCleanRoomLabels

		GOSUB PrintWOLabels			;* Activated WO label printing again -dkk 12/3/14

		* Check to see if they get the monitor wafers based on the PSN

		MonitorWafer = CustEpiPartRec<CUST_EPI_PART_MONITOR_WAFER_LABEL$>

		IF MonitorWafer THEN
			GOSUB PrintMonitorLabels
		END

		* Check to see if they get a surfscan label

		IF (CustNo = '6874') OR (CustNo = '6593') ELSE
			IF ( PreSurfscan ) or ( FirstSurfscan ) or ( PostCleanSurfscan ) THEN
				*GOSUB PrintSurfscanLabels
			END
		END
		Void = UTILITY( 'CURSOR', 'A' )            

	end
	
	GoSub EndPrint

Return


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


* * * * * *
EndPrint:
* * * * * *

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

return


* * * * * * *
PrintCleanRoomLabels:
* * * * * * *
	
	FOR I = 1 TO WMIBoxCnt
		
		WMInKey      = WMInKeys<1,I>
		PrintWMInKey = WMInKey
		CONVERT '*' TO '.' IN PrintWMInKey
		
		CassNo = FIELD(WMInKey,'*',3)
		
		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$>
		Vendor     = WOMatRec<WO_MAT_SUB_VEND_CD$>
		
		OrderDetKey = WORec<WO_LOG_ORDER_NO$>:'*':OrderItem
		
		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
		
		PartNo = CustPartNo				;* Temporary for 4x2 to 4x4 conversion
		PartDesc = CustPartDesc			;* Temporary for 4x2 to 4x4 conversion
		
		SuppCd = TRIM(SubPartNo[-1,'B-'])
		IF LEN(SuppCd) NE '2' THEN SuppCd =''
		
		If CassNo EQ 1 then
			GOSUB PrintCheatSheetLabel
		end
		
		GOSUB PrintLabel
		
		
	NEXT I
	
RETURN


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

	Str	= ''
	For cnt = 1 to 2
		
		Str := '^XA'
		Str := '^LH0,0'
		Str := '^PR2'		;* Print speed 2 inches per second
		Str := '^LL406'		;* Label length @203 dpi
		Str := '^PW900'
		Str := '^MD8'		;* Media darkness
		Str := '^MMT'		;* Media mode t=tear off mode
		
		Str := '^FO15,15^GB795,398,3,B^FS'				;* Border
		
		*Str:= '^FO670,25^A0,36^FDWM Out^FS'
		Str:= '^FO680,25^A0,36^FDWM In^FS'
		
		****** First Line
		Company = 'IFX Epi Services'
		Str := '^FO30,25^A0,,36^FD':Company:'^FS'
		Str := '^FO290,25^AC,18^FDWO No:^FS':CRLF$					
		Str := '^FO370,25^A045,36^FD':PrintWONo:'^FS':CRLF$			
		
		IF CassNo = 1 THEN
			Str := '^FO535,20^GB120,40,40,,3^FS':CRLF$
			Str := '^FO540,25^AC,18^FR^FDCass:^FS':CRLF$			
			Str := '^FO600,25^A045,36^FR^FD':CassNo:'^FS':CRLF$		
		END ELSE
			Str := '^FO540,25^AC,18^FDCass:^FS':CRLF$				
			Str := '^FO600,25^A045,36^FD':CassNo:'^FS':CRLF$		
		END
		
		****** Second Line
		Str:= '^FO30,70^AC,18^FDWM In:^FS':CRLF$
		Str:= '^FO120,70^A050,30^FD':PrintWMInKey:'^FS':CRLF$
		Str := '^BY2,2.0':CRLF$
		Str := '^FO300,60^B3,,37,N^FD':'I':PrintWMInKey:'^FS':CRLF$		
		Str := '^BY2,3.0':CRLF$
		Str:= '^FO700,70^AC,18^FDQty:^FS':CRLF$						
		Str:= '^FO760,70^A045,25^FD':WfrQty:'^FS':CRLF$				
		
		****** Third Line
		Str:= '^FO30,105^AC,18^FDShip Dt:^FS'	
		Str:= '^FO140,105^A0,,25^FD':ReqShipDate:'^FS':CRLF$		
		Str:= '^FO250,105^AC,18^FDCust:^FS':CRLF$					
		Str:= '^FO320,105^A045,25^FD':CustName:'^FS':CRLF$			
		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
		Str := '^FO30,135^AC,18^FDLot No:^FS':CRLF$
		Str := '^FO120,135^A0,20^FD':LotNo:'^FS':CRLF$
		Str := '^FO410,135^AC,18^FDPart No:^FS':CRLF$
		Str := '^FO510,135^A0,20^FD':PartNo:'^FS':CRLF$
		
		****** Fifth Line
		Str := '^FO30,160^AC,18^FDSub PN:^FS':CRLF$
		Str := '^FO120,160^A0,20^FD':SubPartNo:'^FS':CRLF$
		
		IF SuppCd NE '' THEN
			Str := '^FO410,160^AC,18^FDSupp Cd:^FS':CRLF$			
			Str := '^FO510,160^A0,20^FD':SuppCd:'^FS':CRLF$		
			Str := '^BY2,2.0':CRLF$
			Str := '^FO610,160^A040,20^B3,,23,N^FD':SuppCd:'^FS':CRLF$
			Str := '^BY2,3.0':CRLF$
		END
		
		****** Separator bar
		Str := '^FO15,183^GB795,1^FS'
		
		****** Seventh Line
		Str := '^FO30,210^AC,18^FDPre:^FS':CRLF$
		Str := '^FO90,210^A0,20^FD':SubPreClean:'^FS':CRLF$
		
		IF PreAkrionRecipe NE '' THEN
			Str := '^FO210,210^AC,18^FDAkrion:^FS':CRLF$
			Str := '^FO300,210^A0,20^FD':PreAkrionRecipe:'^FS':CRLF$
			Str := '^BY2,2.0':CRLF$
			Str := '^FO450,210^A040,20^B3,,23,N^FD':PreAkrionRecipe:'^FS':CRLF$
			Str := '^BY2,3.0':CRLF$
		END
		
		****** Eighth Line
		Str := '^FO30,235^AC,18^FDRecipe:^FS':CRLF$
		Str := '^FO120,235^A0,20^FD':RecipeInfo:'^FS':CRLF$
		Str := '^FO410,235^AC,18^FDEpi Dopant:^FS':CRLF$
		Str := '^FO560,235^A040,20^FD':Dopant:'^FS':CRLF$
		
		****** Tenth, Eleventh and Twelfth Lines
		Str := '^FO30,285^AC,18^FDThk Spec:^FS':CRLF$
		
		FOR M = 1 TO COUNT(PrintThickTargets,@VM) + (PrintThickTargets NE '')
			BaseLine = 285 + (M-1)*20
			Str := '^FO140,':BaseLine:'^A040,20^FD':PrintThickTargets<1,M>:'^FS':CRLF$
		NEXT M
		
		Str := '^FO410,285^AC,18^FDRes Spec:^FS':CRLF$
		
		FOR M = 1 TO COUNT(PrintResTargets,@VM) + (PrintResTargets NE '')
			BaseLine = 285 + (M-1)*20
			Str := '^FO520,':BaseLine:'^A040,20^FD':PrintResTargets<1,M>:'^FS':CRLF$
		NEXT M
		
		****** Separator bar
		Str := '^FO15,373^GB795,1^FS'
		
		
		****** Fourteenth Line
		Str := '^FO30,385^AC,18^FDProd Spec No:^FS':CRLF$			
		Str := '^FO190,385^A0,25^FD':PSNo:'^FS':CRLF$				
		
		IF SpecType = 'Production' THEN
			SpecType = 'Prod'
		end else IF SpecType = 'Pre-Production' THEN
			SpecType = 'Pre'
		end
		
		Str := '^FO275,385^AC,18^FDSpec Type:^FS':CRLF$				
		Str := '^FO400,385^A0,25^FD':SpecType:'^FS':CRLF$
		
		****** Data Matrix barcode
		Str	:= '^FO720,280^CI28':CRLF$
		Str	:= '^BXN,2,200^FDP':PartNo:'|S':SubPartNo:'|1T':PrintWMInKey:'|2T':LotNo:'|':PSNo:'|Q':WfrQty:'|1V':Vendor:'|SEQ':Cnt:'^FS':CRLF$
		
		Str:= '^XZ'
		
	Next
	
	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		= PSRec<prod_spec_spec_epi$>
	SpecSub		= PSRec<PROD_SPEC_SPEC_SUBSTRATE$>
	
	ThkSmile	= PSRec<PROD_SPEC_THICK_SMILE_REQ$>
	ThkShift	= Field(PSRec, @FM, PROD_SPEC_THICK_LIMIT_SHIFT$)
	
	ResShift	= Field(PSRec, @FM, PROD_SPEC_RES_LIMIT_SHIFT$)
	
	SSRecipe	= XLATE('PRS_STAGE', PSNo:'*LWI', 5, 'X')
	PCRecipe	= XLATE('PRS_STAGE', PSNo, 'POST_CLEAN_SURFSCAN_RECIPE', 'X')
	WaferSize	= 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 ':WONo:'^FS'
	Str := '^FO590,10^A050,30^FDPSN ':PSNo:'^FS'
	Str := '^FO555,40^A050,30^FDDopant ':Dopant:'^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 := '^FO500,310^A050,23^FDSmile Required: ':ThkSmile:'^FS'
	Str := '^FO500,340^A050,23^FDSPC Thk Shift: ':ThkShift:'^FS'
	Str := '^FO500,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



* * * * * * *
PrintBigLabel:
* * * * * * *
	
	Str  = '^XA'				;* Start of label format
	Str := '^LH22,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 := '^PQ2'
	
	
	Str := '^FO15,15^GB795,786,3,B^FS'		;* Border
	Str := '^FO680,25^A0,36^FDWM In^FS'
	
	****** First Line
	
	Str := '^FO30,25^A0,,36^FD':obj_Install('Get_Prop','Company'):'^FS'
	
	
	Str := '^FO290,25^AC,18^FDWO No:^FS':CRLF$					;* Label 
	Str := '^FO370,25^A045,36^FD':PrintWONo:'^FS':CRLF$			;* Data
	
	IF CassNo = 1 THEN
		Str := '^FO535,20^GB120,40,40,,3^FS':CRLF$
		Str := '^FO540,25^AC,18^FR^FDCass:^FS':CRLF$			;* Label 
		Str := '^FO600,25^A045,36^FR^FD':CassNo:'^FS':CRLF$		;* Data
	END ELSE
		Str := '^FO540,25^AC,18^FDCass:^FS':CRLF$				;* Label 
		Str := '^FO600,25^A045,36^FD':CassNo:'^FS':CRLF$		;* Data
	END
	
	
	****** Second Line
	
	Str:= '^FO30,70^AC,18^FDWM In:^FS':CRLF$
	Str:= '^FO120,70^A050,30^FD':PrintWMInKey:'^FS':CRLF$
	
	Str := '^BY2,2.0':CRLF$
	Str := '^FO300,70^B3,,23,N^FD':'I':PrintWMInKey:'^FS':CRLF$
	Str := '^BY2,3.0':CRLF$
	
	Str:= '^FO700,70^AC,18^FDQty:^FS':CRLF$						;* Label
	Str:= '^FO760,70^A045,25^FD':WfrQty:'^FS':CRLF$				;* Data
	
	****** 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
	
	
	****** 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
	
	****** 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
	
	****** 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:= '^XZ'
	
	If Environment_Services('GetLabelPrintMethod') _EQC 'OIPI' then
		stat = Set_Printer('TEXT',Str)
	end else
		stat = Direct_Print('PRINT', Str)
	end
	
RETURN


* * * * * * *
PrintWOLabels:
* * * * * * *
	
* * * * * * *
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 := '^PQ2'			;* Print 2 labels for each pass through here
	STR := '^MMT':CRLF$		;* Media mode t=tear off mode
	
	
	IF INDEX(PrintWONo,'.',1) THEN
		Str:= '^FO10,30^A0,220,210^FD':PrintWONo:'^FS':CRLF$
	END ELSE
		Str:= '^FO70,30^A0,220,210^FD':PrintWONo:'^FS':CRLF$	 		
	END
	
	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:= '^FO160,320^A080,50^FD':'Commit Date: ':OCONV( XLATE( 'WO_LOG', WONo, 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 WMIBoxCnt
		RDSIds  = ''
		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#: ':LotNo<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 WMIBoxCnt
		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'
		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

