compile function PRINT_CLEANROOM_LABELS_THERMAL( RdsIds , MultiStep )
begin condition 
pre:
post:
end condition

$insert logical
$insert msg_equates
$insert rds_equ
$insert rds_layer_info_equ
$insert oiprint_equates
$insert prod_spec_equ
$insert quote_spec_equ
$insert wo_log_equ

declare function fieldcount, msg, key_sort, get_printer, set_printer, entid, choose_zebra_port
declare function repository, print_wo_labels, utility,obj_Install
declare subroutine extract_si_keys
declare function Printer_Select,Set_Printer, Direct_Print, Environment_Services


* * * * * *
* added 9/10/2003 - J.C. Henry, changed printdriver to generic
* eliminated port capture to print, changed printing OI Print Interface 

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(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 = '\\FMSA001\PMSAZBR1'			;* This is the Zebra 105se 
PrinterID = '\\FMSA001\PMSAZBR5'			;* This is the Zebra 105se 
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
if RdsIds then
    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
    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' )            
end


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

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

return 0

*===========================================================================*

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' )
   LotNum           = xlate( 'RDS', RdsIds, rds_lot_num$, 'X' )
   RecipeIDS        = xlate( 'RDS', RdsIds, rds_recipe_no$, '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' )									;* 5/21/2005 - JCH - Added for Order Entry/Vision upgrade
   PsnCRLabelInst	= XLATE( 'PROD_SPEC', PSNIds, PROD_SPEC_CR_LABEL_INST$, 'X' )
  
   *****************
   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 = ''
   *convert @lower_case to @upper_case in SpecType
   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$
      end
      if ( ThisRunOrdNum = WOBoxCnt ) and ( ThickLast ) then
         PrintThickness = true$
      end
      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 
      end
      if PrintThickness then
         PSNRec    = xlate( 'PROD_SPEC', PSNIds<i>, '', 'X' )
         SpecSub   = PSNRec<prod_spec_spec_substrate$>
         *if ThickType <> 'Prod' then
            TOrient = SpecSub<1,QSSubOrientation$>
            convert '<' to '' in TOrient
            convert '>' to '' in TOrient
            Orient = TOrient
         *end else
         *   Orient = ''
         *end
         ThickPrintVar<i> = ThickTool:'~':ThickType:'~':Orient:'~':ThickRecipe
      end else
         ThickPrintVar<i> = ''
      end
      * NOW CHECK RESISTIVITY
      PrintResistivity = false$
      if ( ThisRunOrdNum = 1 ) and ( ResFirst ) then
         PrintResistivity = true$
      end
      if ( ThisRunOrdNum = WOBoxCnt ) and ( ResLast ) then
         PrintResistivity = true$
      end
      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 
      end
      if PrintResistivity then
         PSNRec    = xlate( 'PROD_SPEC', PSNIds<i>, '', 'X' )
         SpecSub   = PSNRec<prod_spec_spec_substrate$>
         *if ResType <> 'Prod' then
            TOrient = SpecSub<1,QSSubOrientation$>
            convert '<' to '' in TOrient
            convert '>' to '' in TOrient
            Orient = TOrient
         *end else
         *   Orient = ''
         *end
         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 PrintSRP then
	         * WE ARE ALREADY PRINTING IT SO NO NEED TO CHECK OTHER METROLOGY
	      end else
	        * NOW NEED TO CHECK CONCENTRATION
	        if ConTool = 'SRP' then
		        if ( ThisRunOrdNum = 1 ) and ( ConFirst ) then
		           PrintSRP = true$
		        end
		        if ( ThisRunOrdNum = WOBoxCnt ) and ( ConLast ) then
		           PrintSRP = true$
		        end
		        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
		     end
		     if PrintSRP then
		        SRPType = ConType   
		     end
         end
         if PrintSRP then
	         * WE ARE ALREADY PRINTING IT SO NO NEED TO CHECK OTHER METROLOGY
	      end else
	        * NOW NEED TO CHECK STRESS
	        if StressTool = 'SRP' then
		        if ( ThisRunOrdNum = 1 ) and ( StressFirst ) then
		           PrintSRP = true$
		        end
		        if ( ThisRunOrdNum = WOBoxCnt ) and ( StressLast ) then
		           PrintSRP = true$
		        end
		        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
		     end
		     if PrintSRP then
		        SRPType = StressType
		     end
	      end
         if PrintSRP then
	         * WE ARE ALREADY PRINTING IT SO NO NEED TO CHECK OTHER METROLOGY
	      end else
	        * NOW NEED TO CHECK TRANSITION
	        if TransTool = 'SRP' then
		        if ( ThisRunOrdNum = 1 ) and ( TransFirst ) then
		           PrintSRP = true$
		        end
		        if ( ThisRunOrdNum = WOBoxCnt ) and ( TransLast ) then
		           PrintSRP = true$
		        end
		        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                 
		           end 
		        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
	NewCustName = ''; NewWO = '';NewCustName = '';NewLotNum = ''; NewCustName = ''
	NewRecipeInfo = ''; NewSpecType = ''; NewRONum = ''; NewRdsIds = ''
	NewThickPrintVar = ''; NewResPrintVar = ''; NewMultiLayVar = ''; NewSRPPrintVar = ''
	NewSRPTypePrintVar = ''; NewQtys = ''; NewThickTarget = ''
	NewResTarget = ''; NewPO = ''; NewPartNum = ''; NewDopant = ''
	NewShipBagReq = ''; NewReqShipDate = ''; NewCleaningReqs = ''
	NewPSNNo = ''
	for i = 1 to IdCnt
		NewCustName<-1>        = CustName<i>:@fm: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
		
		NewWO<-1>              = WoNo:@fm:WoNo		 		;* 5/21/2005 - JCH - Changed for Order Entry/Vision upgrade
		NewPSNNo<-1>		   = PSNIds<i>:@FM:PSNIds<i>	;* 6/10/2005 - JCH - Added per manufacturing manager request 
		
		NewLotNum<-1>          = LotNum<i>:@fm:LotNum<i>
		NewRecipeInfo<-1>      = RecipeInfo<i>:@fm:RecipeInfo<i>
		NewSpecType<-1>        = SpecType<i>:@fm:SpecType<i>               
		NewRONum<-1>           = RONum<i>:@fm:RONum<i>
		NewRdsIds<-1>          = RdsIds<i>:@fm:RdsIds<i>
		NewThickPrintVar<-1>   = ThickPrintVar<i>:@fm:ThickPrintVar<i>
		NewResPrintVar<-1>     = ResPrintVar<i>:@fm:ResPrintVar<i>
		NewMultiLayVar<-1>     = MultiLayVar<i>:@fm:MultiLayVar<i>
		NewSRPPrintVar<-1>     = SRPPrintVar<i>:@fm:SRPPrintVar<i>
		NewSRPTypePrintVar<-1> = SRpTypePrintVar<i>:@fm:SRPTypePrintVar<i>
		NewQtys<-1>            = Qtys<i>:@fm:Qtys<i>
		ThickCnt = fieldcount( ThickTarget<i>, @vm )
		ThickTargetString = ''
		for j = 1 to ThickCnt
			ThickTargetString:= ThickTarget<i,j>:ThickUnit<i,j>:';' 
		next j
		ThickTargetString[-1,1] = ''
		NewThickTarget<-1>     = ThickTargetString:@fm:ThickTargetString
		ResCnt = fieldcount( ResTarget<i>, @vm )
		ResTargetString = ''
		for j = 1 to ResCnt
			ResTargetString:= ResTarget<i,j>:ResUnit<i,j>:';'
		next j
		ResTargetString[-1,1] = ''
		NewResTarget<-1>       = ResTargetString:@fm:ResTargetString
		NewPO<-1>              = PO<i>:@fm:PO<i>
		NewPartNum<-1>         = PartNum<i>:'Sub Part# ':SubPartNum<i>:@fm:PartNum<i>:'Sub Part# ':SubPartNum<i>
		NewDopant<-1>          = Dopant<i>:@fm:Dopant<i>
		NewShipBagReq<-1>      = ShipBagReq<i>:@fm:ShipBagReq<i>
		NewReqShipDate<-1>     = ReqShipDate<i>:@fm:ReqShipDate<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
		Tvar                   = trim( 'Strip:':SubOxide<i>:' Pre:':SubPreClean<i>:APreRec:' Post:':SubPostClean<i>:APostRec )
		Tvar                  := @fm:Tvar
		NewCleaningReqs<-1>    = Tvar
	next i
	   
	transfer NewCustName		to CustName
	transfer NewWO 				to WO
	transfer NewPSNNo			to PSNNo
	transfer NewLotNum			to LotNum
	transfer NewRecipeInfo		to RecipeInfo
	transfer NewSpecType		to SpecType
	transfer NewRONum			to RONum
	transfer NewRdsIds			to RdsIds
	transfer NewThickPrintVar	to ThickPrintVar
	transfer NewResPrintVar		to ResPrintVar
	transfer NewMultiLayVar		to MultiLayVar
	transfer NewSRPPrintVar		to SRPPrintVar
	transfer NewSRPTypePrintVar	to SRpTypePrintVar
	transfer NewQtys			to Qtys
	transfer NewThickTarget		to ThickTarget
	transfer NewResTarget		to ResTarget
	transfer NewPO				to PO
	transfer NewPartNum			to PartNum
	transfer NewDopant			to Dopant
	transfer NewShipBagReq		to ShipBagReq
	transfer NewReqShipDate		to ReqShipDate
	transfer NewCleaningReqs	to CleaningReqs 
	   
	IdCnt += IdCnt ;* SO WE PRINT TWO SETS OF LABELS

	for i = 1 to IdCnt step 2
		PrintThickTarget   = ThickTarget<i>
		PrintResTarget     = ResTarget<i>
		PrintCustName      = CustName<i>
		PrintWO            = WO<i>
		PrintPSNNo		   = PSNNo<i>
		PrintPO            = PO<i>
		PrintDopant        = Dopant<i>
		PrintPartNum       = PartNum<i>
		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>
		PrintShipBagReq        = ShipBagReq<i>
		PrintReqShipDate     = ReqShipDate<i>
		PrintCleaningReqs    = CleaningReqs<i>
		gosub PrintLabel 
		*
		PrintThickTarget     = ThickTarget<i+1>
		PrintResTarget       = ResTarget<i+1>
		PrintCustName        = CustName<i+1>
		PrintWO              = WO<i+1>
		PrintPSNNo			 = PSNNo<i+1>
		PrintPO              = PO<i+1>
		PrintDopant          = Dopant<i+1>
		PrintPartNum         = PartNum<i+1>
		PrintLotNum          = LotNum<i+1>
		PrintRecipeInfo      = RecipeInfo<i+1>
		PrintSpecType        = SpecType<i+1>
		PrintRONum           = RONum<i+1>
		PrintRdsId           = RdsIds<i+1>
		PrintThickPrintVar   = ThickPrintVar<i+1>
		PrintResPrintVar     = ResPrintVar<i+1>
		PrintMultiLayVar     = MultiLayVar<i+1>
		PrintSRPPrintVar     = SRPPrintVar<i+1>
		PrintSRPTypePrintVar = SRPTypePrintVar<i+1>
		PrintQty             = Qtys<i+1>
		PrintShipBagReq        = ShipBagReq<i+1>
		PrintReqShipDate     = ReqShipDate<i+1>
		PrintCleaningReqs    = CleaningReqs<i+1>		   		   
		gosub PrintLabel		   
	next i
	  
return
*===========================================================================*
PrintLabel:

MakeupBox = XLATE('RDS',PrintRdsId,RDS_MAKEUP_BOX$,'X')	;* I give up on this mess


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 := CRLF$
Str := '^FO15,20^GB800,318,5,B^FS':CRLF$

* SRP Box and info in Upper Right Corner of label

if PrintSrpPrintVar then
   Str:= '^FO742,20^GB72,60,3,B^FS':CRLF$
   Str:= '^FO755,30^A045,25^FDSRP^FS':CRLF$
   if len( PrintSRPTypePrintVar ) > 2 then
      Str:= '^FO755,55^A045,25^FD':PrintSRPTypePrintVar:'^FS':CRLF$      
   end else
      Str:= '^FO765,55^A045,25^FD':PrintSRPTypePrintVar:'^FS':CRLF$   
   end   
end

IF PrintRONum = 1 THEN

   * Box bagging reqs, rds and run order num as a flag for first box
   
   Str:= '^FO420,130^GB375,95,3,B^FS':CRLF$
   Str:= '^FO700,200^A045,25^FDFirst Box^FS':CRLF$     
END

* First Line

Str:= '^FO30,30^A050,35^FD':obj_Install('Get_Prop','Company'):'^FS':CRLF$
Str:= '^FO470,30^A050,35^FD':quote(PrintSpecType):'^FS':CRLF$

* Second Line

Str:= '^FO30,65^A045,25^FDRequested Ship Date:^FS':CRLF$	;* Label
Str:= '^FO265,65^A045,25^FD':PrintReqShipDate:'^FS':CRLF$	;* Data

IF MakeupBox THEN
	Str := '^FO380,60^A050,35^FD* * M a k e u p  B o x * *^FS':CRLF$
END

* Third Line

Str:= '^FO30,90^A045,25^FDWork Order No:^FS':CRLF$			;* Label 
Str:= '^FO190,90^A045,25^FD':PrintWO:'^FS':CRLF$			;* Data
Str:= '^FO320,90^A045,25^FDQty:^FS':CRLF$					;* Label
Str:= '^FO370,90^A045,25^FD':PrintQty:'^FS':CRLF$			;* Data
Str:= '^FO430,90^A045,25^FDCustomer:^FS':CRLF$				;* Label
Str:= '^FO550,90^A045,25^FD':PrintCustName:'^FS':CRLF$		;* Data


* Last Line

Str:= '^FO30,305^A045,25^FDProd Spec No:^FS':CRLF$					;* Label
Str:= '^FO200,305^A045,25^FD':PrintPSNNo:'^FS':CRLF$		;* Data


* Original mess from here on

Str:= '^FO30,140^A040,20^FDLot No:^FS':CRLF$
Str:= '^FO30,170^A040,20^FDPurchase Order No:^FS':CRLF$
Str:= '^FO30,200^A040,20^FDPart#^FS':CRLF$
Str:= '^FO30,230^A040,20^FDRecipe:^FS':CRLF$
Str:= '^FO30,280^A040,20^FDThk Spec:^FS':CRLF$

* RIGHT COLUMNS

Str:= '^FO430,140^A040,20^FDBagging:^FS':CRLF$
Str:= '^FO430,170^A040,20^FDRun No:^FS':CRLF$
Str:= '^FO430,200^A040,20^FDRDS No:^FS':CRLF$
Str:= '^FO430,230^A040,20^FDEpi Dopant:^FS':CRLF$
Str:= '^FO430,280^A040,20^FDRes Spec:^FS':CRLF$

* LEFT DATA

if PrintMultiLayVar then
   PrintMultiLayVar = 'MULTI-LAYER VIEW-RDS'
end else
   PrintMultiLayVar = ''
end
swap '~' with fmt( ' ', 'L#2' ) in PrintThickPrintVar
swap 'æm' with 'um' in PrintThickTarget
swap 'ê-cm' with 'ohm.cm' in PrintThickTarget
swap 'ê/Ü' with 'ohm/sq' in PrintThickTarget
swap '' with 'A' in PrintThickTarget   


Str:= '^FO30,115^A040,20^FD':PrintCleaningReqs:'^FS':CRLF$
Str:= '^FO560,115^A045,20^FD':PrintMultiLayVar:'^FS':CRLF$

Str:= '^FO98,140^A040,20^FD':PrintLotNum:'^FS':CRLF$
Str:= '^FO200,170^A040,20^FD':PrintPO:'^FS':CRLF$
Str:= '^FO80,200^A040,20^FD':PrintPartNum:'^FS':CRLF$
Str:= '^FO100,230^A040,20^FD':PrintRecipeInfo:'^FS':CRLF$
Str:= '^FO30,255^A040,20^FD':PrintThickPrintVar:'^FS':CRLF$
Str:= '^FO118,280^A040,20^FD':PrintThickTarget:'^FS':CRLF$

* RIGHT DATA

swap '~' with fmt( ' ', 'L#2' ) in PrintResPrintVar
swap 'æm' with 'um' in PrintResTarget
swap 'ê-cm' with 'ohm.cm' in PrintResTarget
swap 'ê/Ü' with 'ohm/sq' in PrintResTarget
swap '' with 'A' in PrintResTarget
*convert @vm to ',' in PrintShipBagReq




Str:= '^FO525,140^A040,20^FD':PrintShipBagReq:'^FS':CRLF$

Str:= '^FO500,170^A040,20^FD':PrintRONum:'^FS':CRLF$

Str := '^BY2,2.0':CRLF$
Str := '^FO550,167^A040,20^B3,,23,N^FD':PrintRDSId:'^FS':CRLF$
Str := '^BY2,3.0':CRLF$

Str:= '^FO550,195^A050,30^FD':PrintRDSId:'^FS':CRLF$
Str:= '^FO530,230^A040,20^FD':PrintDopant:'^FS':CRLF$
Str:= '^FO430,255^A040,20^FD':PrintResPrintVar:'^FS':CRLF$
Str:= '^FO520,280^A040,20^FD':PrintResTarget:'^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 0
*===========================================================================*
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,30^A0220,210^FD':PrintUniqueWO:'^FS':CRLF$	 		;* 5/21/2005 - JCH - Changed for Order Entry/Vision upgrade
END ELSE
	Str:= '^FO70,30^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,210^A110,70^FD':CustAbbrevOrName:'^FS':CRLF$
Str:= '^FO150,280^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
*oswrite Str on DosPath$					;* remove JCH
*Var1 = DosPath$							;* remove JCH
*Void = Utility("COPYFILE", Var1, Var2)	;* remove JCH
return


*===========================================================================*
PrintMonitorLabels:
for i = 1 to IdCnt step 2
	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
	
	*oswrite Str on DosPath$					;* remove JCH
	*Var1 = DosPath$							;* remove JCH
	*Void = Utility("COPYFILE", Var1, Var2)	;* remove JCH					
next i
return
*===========================================================================*
PrintSurfscanLabels:
for i = 1 to IdCnt step 2
	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	
	*oswrite Str on DosPath$					;* remove JCH
	*Var1 = DosPath$							;* remove JCH
	*Void = Utility("COPYFILE", Var1, Var2)	;* remove JCH	
next i
*===========================================================================*
