COMPILE SUBROUTINE PRINT_WM_IN_LABELS(WO_No , MultiStep )

***** This appears to be dead JCH


$INSERT LOGICAL
$INSERT MSG_EQUATES
$INSERT OIPRINT_EQUATES
$INSERT PROD_SPEC_EQUATES
$INSERT QUOTE_SPEC_EQU
$INSERT WO_LOG_EQU
$INSERT ORDER_DET_EQU
$INSERT WM_IN_EQUATES

DECLARE FUNCTION  Msg,  Get_Printer, Set_Printer, Utility, obj_Install, Printer_Select, FieldCount
Declare function    Direct_Print, Environment_Services
DECLARE SUBROUTINE Btree.Extract, ErrMsg


* 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

IF NOT(ASSIGNED(WONo))		THEN WONo = ''				;* 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 WONo = '' 		THEN RETURN							;* 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 = '\\FMSA001\PMSAZ_BR3'			;* Print Server change
PrinterID = '\\mesirwfp001\MESZBRPRT002'	;* This is the Zebra 105sl with the test labels loaded

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

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

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

SearchString = 'WO_NO':@VM:WONo:@FM

Btree.Extract(SearchString,'WM_IN',DictVar,WMInKeys,'',Flag)
IF Get_Status(errCode) THEN
	ErrMsg(errCode)
	RETURN
END

IF WMInKeys = '' THEN RETURN


debug
return
Void = utility( 'CURSOR', 'H' )
IdCnt = COUNT( RdsIds, @FM ) + (RdsIds NE '')

IF IdCnt > 1 THEN
   * RdsIds = key_sort( RdsIds, 'RDS', 'WO':@FM:'RUN_ORDER_NUM', 1, '', '' )
END

RETURN
GOSUB PrintCleanRoomLabels
   
UniqueWOs = ''

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
		LOCATE ThisWO IN UniqueWOs USING @VM SETTING FPos ELSE
			UniqueWOs<1,-1> = ThisWO
		END
	NEXT I
	
END ELSE

	AllWOs = XLATE( 'RDS', RdsIds, rds_wo$, 'X' )
	FOR I = 1 TO IdCnt
		ThisWO = AllWOs<I>
		LOCATE ThisWO IN UniqueWOs USING @VM SETTING Fpos ELSE
			UniqueWOs<1,-1> = ThisWO
		END 
	NEXT I
	
END

   GOSUB PrintWOLabels
   
  
   * Check to see if they get the monitor wafers based on the psn using the first of RdsIDs
   
IF XLATE( 'PROD_SPEC', XLATE( 'RDS', RdsIds<1>, rds_prod_spec_id$, 'X' ), prod_spec_monitor_wafer_label$, 'X' ) THEN
	GOSUB PrintMonitorLabels
END

* Check to see if they get a surfscan label
CustNo = XLATE('RDS',RdsIds<1>,rds_cust_no$,'X')
IF (CustNo = '6874') OR (CustNo = '6593') ELSE
	IF ( PreSurfscan ) or ( FirstSurfscan ) or ( PostCleanSurfscan ) THEN
		GOSUB PrintSurfscanLabels
	END
END
Void = UTILITY( 'CURSOR', 'A' )            



* * * * * *
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:
* * * * * * *

CustName			= XLATE( 'RDS', RdsIds, 'ABBREV_OR_CO_NAME', 'X' )
WO					= XLATE( 'RDS', RdsIds, rds_wo$, 'X' )
ShipBagReq			= XLATE( 'RDS', RdsIds, 'SHIP_BAG_REQ', 'X' )
ReqShipDate			= OCONV( XLATE( 'WO_LOG', WO, WO_LOG_PROMISE_SHIP_DT$, 'X' ), 'D2/' )
PO					= XLATE( 'RDS', RdsIds, rds_po$, 'X' )
PartNum				= XLATE( 'RDS', RdsIds, rds_part_num$, 'X' )

ThickTarget			= OCONV( XLATE( 'RDS', RdsIds, 'THICK_TARGET_ALL', 'X' ), 'MD2' )
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' )								;* Changed to calculated field 4/14/2006 JCH

LotNum				= XLATE( 'RDS', RdsIds, rds_lot_num$, 'X' )
RecipeInfo			= XLATE( 'RECIPE', RecipeIDS, 'RECIPE_NAME_NO', 'X' )

RONum				= XLATE( 'RDS', RdsIds, 'RUN_ORDER_NUM', 'X' )
PSNIds				= XLATE( 'RDS', RdsIds, rds_prod_spec_id$, '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' )

SpecType			= OCONV( XLATE( 'RDS', RdsIds, 'SPEC_TYPE', 'X' ), '[SPEC_TYPE_CONV]' )
SubOxide			= OCONV( XLATE( 'PROD_SPEC', PSNIds, 'SUB_OXIDE_STRIP', 'X' ), 'B' )
SubPreClean			= XLATE( 'PROD_SPEC', PSNIds, 'SUB_PRE_CLEAN', 'X' )
SubPostClean		= XLATE( 'PROD_SPEC', PSNIds, 'SUB_POST_CLEAN', 'X' )
PreAkrionRecipe		= XLATE( 'PROD_SPEC', PSNIds, 'PRE_AKRION_RECIPE', 'X' )   
PostAkrionRecipe	= XLATE( 'PROD_SPEC', PSNIds, 'POST_AKRION_RECIPE', 'X' )
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

OrderNos			= XLATE( 'RDS',RdsIds,RDS_ORDER_NO$,'X' )								;* 10/04/2005 - JCH - Added for Order Entry/Vision upgrade
OrderItems			= XLATE( 'RDS',RdsIds,RDS_ORDER_ITEM$,'X' )								;* 10/04/2005 - JCH - Added for Order Entry/Vision upgrade

OrderDetKeys = ''
FOR I = 1 TO COUNT(OrderNos,@FM) + (OrderNos NE '')
	OrderDetKeys<I> = OrderNos<I>:'*':OrderItems<I>
NEXT I
	
CustPNDescs			= XLATE( 'ORDER_DET',OrderDetKeys,ORDER_DET_CUST_PN_DESC$,'X')					;* 10/04/2005 - JCH - Added for Order Entry/Vision upgrade	

PreSurfscan			= XLATE( 'PROD_SPEC', PSNIds<1>, prod_spec_pre_surfscan$, 'X' )
FirstSurfscan		= XLATE( 'PROD_SPEC', PSNIds<1>, prod_spec_first_surfscan$, 'X' )
PostCleanSurfscan	= XLATE( 'PROD_SPEC', PSNIds<1>, prod_spec_post_clean_surfscan$, 'X' )

CleaningReqs		= ''

SRPFlag				= XLATE( 'PROD_SPEC', PSNIds, 'SRP_REQ', 'X' )
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$>

		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>
	PrintSubPartNum			= SubPartNum<I>
	
	SuppCd = SubPartNum<I>[-1,'B-']
	IF LEN(SuppCd) NE '2' THEN SuppCd =''
	
	PrintSuppCd				= SuppCd
	
	PrintDopant				= Dopant<I>
	PrintShipBagReq			= ShipBagReq<I>
	PrintReqShipDate		= ReqShipDate<I>
	
	PrintSubOxide			= SubOxide<I>
	PrintSubPreClean		= SubPreClean<I>
	PrintSubPostClean		= SubPostClean<I>
	PrintPreAkrionRecipe	= PreAkrionRecipe<I>
	PrintPostAkrionRecipe	= PostAkrionRecipe<I>
	
	
	APreRec  = ''
	APostRec = ''
	IF ( PreAkrionRecipe<I> <> '' ) THEN
		APreRec = ' ':PreAkrionRecipe<I>:' '
		SubOxide<I> = 'No' ;* IF AKRION THEN NO OXIDE STRIP
	END
	
	IF ( PostAkrionRecipe<I> <> '' ) THEN
		APostRec = ' ':PostAkrionRecipe<I>
	END
	*PrintCleaningReqs	= TRIM( 'Strip:':SubOxide<I>:' Pre:':SubPreClean<I>:APreRec:' Post:':SubPostClean<I>:APostRec )
	PrintCleaningReqs	= TRIM( 'Strip:':SubOxide<I>:' Pre:':SubPreClean<I>:APreRec:' Post:':SubPostClean<I>:APostRec )

	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
	
	GOSUB PrintLabel
	
NEXT I
  
RETURN


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

MakeupBox = XLATE('RDS',PrintRdsId,RDS_MAKEUP_BOX$,'X')	


Str = '^XA'
Str := '^LH0,0'
Str := '^PR2'		;* Print speed 2 inches per second
Str := '^LL406'		;* 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 := '^FO15,15^GB795,398,3,B^FS'

* SRP Box and info in Upper Right Corner of label

IF PrintSRPPrintVar THEN
   Str:= '^FO738,15^GB72,60,3,B^FS'
   Str:= '^FO755,25^A0,25^FDSRP^FS'
   
   
   IF LEN( PrintSRPTypePrintVar ) > 2 THEN
      Str:= '^FO750,50^A0,,25^FD':PrintSRPTypePrintVar:'^FS':CRLF$
   END ELSE
      Str:= '^FO740,50^A0,,25^FD':PrintSRPTypePrintVar:'^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':PrintWO:'^FS':CRLF$			;* Data

IF PrintRONum = 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':PrintRONum:'^FS':CRLF$		;* Data
	
END ELSE
	Str := '^FO560,25^AC,18^FDRun:^FS':CRLF$					;* Label 
	Str := '^FO615,25^A045,36^FD':PrintRONum:'^FS':CRLF$		;* Data
END


****** Second Line

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

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

Str:= '^FO450,70^AC,18^FDQty:^FS':CRLF$						;* Label
Str:= '^FO510,70^A045,25^FD':PrintQty:'^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':PrintReqShipDate:'^FS':CRLF$	;* Data

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

Str:= '^FO560,105^AC,18^FDPO:^FS':CRLF$
Str:= '^FO600,105^A045,25^FD':PrintPO:'^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':PrintLotNum:'^FS':CRLF$

Str := '^FO410,135^AC,18^FDPart No:^FS':CRLF$
Str := '^FO510,135^A0,20^FD':PrintPartNum:'^FS':CRLF$


****** Fifth Line

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

IF PrintSuppCd NE '' THEN

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


****** Separator bar

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


****** Sixth Line

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

****** Seventh Line

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

IF PrintPreAkrionRecipe NE '' THEN
	Str := '^FO210,210^AC,18^FDAkrion:^FS':CRLF$
	Str := '^FO300,210^A0,20^FD':PrintPreAkrionRecipe:'^FS':CRLF$

	Str := '^BY2,2.0':CRLF$
	Str := '^FO450,210^A040,20^B3,,23,N^FD':PrintPreAkrionRecipe:'^FS':CRLF$
	Str := '^BY2,3.0':CRLF$
END


****** Eighth Line

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

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


****** Ninth Line

Str := '^FO30,260^A040,20^FD':PrintThickPrintVar:'^FS':CRLF$
Str := '^FO410,260^A040,20^FD':PrintResPrintVar:'^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

****** The Line with No Name

IF PrintPostAkrionRecipe NE '' THEN
	Str := '^FO30,350^AC,18^FDPost:^FS':CRLF$
	Str := '^FO90,350^A0,20^FD':PrintSubPostClean:'^FS':CRLF$
	
	Str := '^FO210,350^AC,18^FDAkrion:^FS':CRLF$
	Str := '^FO300,350^A0,20^FD':PrintPostAkrionRecipe:'^FS':CRLF$
	
	Str := '^BY2,2.0':CRLF$
	Str := '^FO450,350^A040,20^B3,,23,N^FD':PrintPostAkrionRecipe:'^FS':CRLF$
	Str := '^BY2,3.0':CRLF$
END ELSE
	
	Str := '^FO30,350^AC,18^FDPost:^FS':CRLF$
	Str := '^FO120,350^A0,20^FD':PrintSubPostClean:'^FS':CRLF$
END


****** Separator bar

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


****** Fourteenth Line

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


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

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


Str:= '^FO480,385^AC,18^FDBag:^FS':CRLF$
Str:= '^FO530,385^A0,20^FD':PrintShipBagReq:'^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(RdsIds,@VM) + (RdsIds NE '')
ShelfCnt = INT(RDSCnt/28) + (MOD(RDSCnt,28) NE 0)		;* Come back TO this later JCH 7/27/2005

NewUniqueWOs = ''
UWOCnt = fieldcount( UniqueWOs, @VM )
FOR I = 1 TO UWOCnt
	NewUniqueWOs<1,-1> = UniqueWOs<1,I>:@VM:UniqueWOs<1,I>
NEXT I

TRANSFER NewUniqueWOs TO UniqueWOs
UWOCnt += UWOCnt

* So we print two sets of labels           	         

FOR I = 1 TO UWOCnt step 2
   PrintUniqueWO = UniqueWOs<1,i>
   GOSUB PrintWO
 PrintUniqueWO = UniqueWOs<1,i+1>
 GOSUB PrintWO
NEXT I 
   
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,05^A0220,210^FD':PrintUniqueWO:'^FS':CRLF$	 		;* 5/21/2005 - JCH - Changed for Order Entry/Vision upgrade
END ELSE
	Str:= '^FO70,05^A0220,210^FD':PrintUniqueWO:'^FS':CRLF$	 		
END

* GET CUST ABBREV

CustNo = XLATE( 'WO_LOG', PrintUniqueWO[1,'.'], wo_log_cust_no$, 'X' )
CustAbbrevOrName = XLATE( 'COMPANY', CustNo, 'ABBREV_OR_CO_NAME', 'X' )

Str:= '^FO30,185^A110,70^FD':CustAbbrevOrName:'^FS':CRLF$
Str:= '^FO150,255^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





