COMPILE FUNCTION obj_Zebra160s(Method,Parms)
/*
	Methods for Printing on Zebra 160s
    
	08/26/2003 JCH - Initial Coding
     
    Properties:
     
    Methods:
    
    ContainerLabel(ParmList)		- Prints Delphi Container Label (6"W x 4"H)
    MasterLabel(ParmList) 			- Prints Delphi Master Label
    MixedLoadLabel(ParmList)		- Prints Delphi Mixed Load Label
   
*/


DECLARE FUNCTION Set_Printer, Get_Printer, Get_Status, Msg, Printer_Select,Get_Property
DECLARE FUNCTION Utility, Printsetup, obj_Install, Direct_Print, Environment_Services
DECLARE SUBROUTINE  Set_Status, Msg, ErrMsg

$INSERT OIPRINT_EQUATES
$INSERT MSG_EQUATES
$INSERT PRINTSETUP_EQUATES

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


ErrTitle = 'Error in Stored Procedure "obj_Zebra160s"'
ErrorMsg = ''

IF NOT(ASSIGNED(Method))	THEN ErrorMsg = 'Unassigned parameter "Method" passed to subroutine'
IF NOT(ASSIGNED(Parms))		THEN Parms = ''

IF ErrorMsg NE '' THEN
	Set_Status(-1,ErrTitle:@SVM:ErrorMsg)
	RETURN ''
END

Methods  = 'ContainerLabel':@FM
Methods := 'MasterLabel':@FM
Methods := 'MixedLoadLabel':@FM

Result = ''

LOCATE Method IN Methods USING @FM SETTING Pos THEN
	ON Pos GOSUB ContainerLabel,MasterLabel,MixedLoadLabel
END

IF ErrorMsg NE '' THEN
	Set_Status(-1,ErrTitle:@SVM:ErrorMsg)
	RETURN ''
END

RETURN Result

* * * * * * *
ContainerLabel:
* * * * * * *

CustPartNo		= Parms[1,@RM]			;* Customer Part No				- 18 alphanumeric
PartQty			= Parms[COL2()+1,@RM]	;* Part Qty 					- 6  numeric
PONo			= Parms[COL2()+1,@RM]	;* Purchase Order No			- 12 alphanumeric
RevLvl			= Parms[COL2()+1,@RM]	;* Engineering Change or Rev	- 3  alpha
SupplierCd		= Parms[COL2()+1,@RM]	;* Customer supplied Vend ID	- 12 alphanumeric
DeliveryLoc		= Parms[COL2()+1,@RM]	;* Delivery Location			- 8  char (VARIOUS is OK)
SerialNo		= Parms[COL2()+1,@RM]	;* EDI transaction serial no	- 9  alpha 
PlantDock		= Parms[COL2()+1,@RM]	;* Plant & Dock designator		- 7  character
LotNo			= Parms[COL2()+1,@RM]	;* Vendor Lot Number			- 10 character
StorageBin		= Parms[COL2()+1,@RM]	;* Storage Bin at Customer		- 30 character
PlantName		= Parms[COL2()+1,@RM]	;* Ship to Plant Name			- 30 character
PlantCity		= Parms[COL2()+1,@RM]	;* Ship to Plant City			- 30 character
MfgDt			= Parms[COL2()+1,@RM]	;* Date of Manufacture			- MM/DD/YYYY
PartDesc		= Parms[COL2()+1,@RM]	;* Part Description				- 25 character
CartonNo		= Parms[COL2()+1,@RM]	;* Carton sequence number
CartonQty		= Parms[COL2()+1,@RM]	;* Total cartons in group
Manufacturer	= Parms[COL2()+1,@RM]	;* Manufacturer					- 30 character
City			= Parms[COL2()+1,@RM]	;* Mfr City						- 20 character
ST				= Parms[COL2()+1,@RM]	;* Mfr State code				- 2  character
ZIP				= Parms[COL2()+1,@RM]	;* ZIP code						- 7  character
Country			= Parms[COL2()+1,@RM]	;* Country of origin			- 10 character


IF CustPartNo	= '' THEN ErrorMsg = 'Null parm CustPartNo passed to routine (':Method:').'
IF PartQty		= '' THEN ErrorMsg = 'Null parm PartQty passed to routine (':Method:').'
IF SupplierCd	= '' THEN ErrorMsg = 'Null parm SupplierCd passed to routine (':Method:').'
IF MfgDt		= '' THEN ErrorMsg = 'Null parm MfgDate passed to routine (':Method:').'
IF PartDesc		= '' THEN ErrorMsg = 'Null parm PartDesc passed to routine (':Method:').'

IF ErrorMsg NE '' THEN
	Set_Status(-1,'',ErrorMsg)
	RETURN
END


*Start Printing Process

GOSUB OIPIInit	;* Selects printer and initializes OIPrinter Interface
GOSUB Label6x4	;* Zebra printer setup and background lines for labels 

* * * * * * *
* Top Block Left - Customer Part Number
* * * * * * *

LabelString := '^BY2':CRLF$						;* This is Code 128 Barcode - change ratio

LabelString := '^FO0,0^A0,25^FDPart #:^FS':CRLF$					;* Label Line 1
LabelString := '^FO0,30^A0,25^FDCust(P)^FS':CRLF$					;* Label Line 2
LabelString := '^FO100,0^A0,120,60^FD':CustPartNo:'^FS':CRLF$		;* Readable
LabelString := '^FO100,100^BC,100,N^FDP':CustPartNo:'^FS':CRLF$		;* Code 128

LabelString := '^BY3,3.0':CRLF$					;* Reset narrow bar width and Ratio

* * * * * * *
* Top Block Right - Quantity
* * * * * * *

LabelString := '^FO700,105^A0,25^FDQuantity:^FS':CRLF$			;* Label Line 1
LabelString := '^FO700,135^A0,25^FD(Q)^FS':CRLF$				;* Label Line 2
LabelString := '^FO810,105^A0,120,60^FD':PartQty:'^FS':CRLF$	;* Readable
LabelString := '^FO700,0^B3,,100,N^FDQ':PartQty:'^FS':CRLF$		;* Code 39

* * * * * * *
* 2nd Block Left - PO No
* * * * * * *

LabelString := '^FO0,208^A0,25^FDP.O.:^FS':CRLF$				;* Label Line 1
LabelString := '^FO0,238^A0,25^FD(K)^FS':CRLF$					;* Label Line 2
LabelString := '^FO100,208^A0,120,60^FD':PONo:'^FS':CRLF$		;* Readable

IF LEN(PONo) > 8 THEN
	LabelString := '^BY2':CRLF$									;* Min bar width to 2 dots
	LabelString := '^FO100,303^BC,100,N^FDK':PONo:'^FS':CRLF$	;* Code 128
	LabelString := '^BY3,3.0':CRLF$								;* Reset bar width and Ratio
END ELSE
	LabelString := '^FO100,303^B3,,100,N^FDK':PONo:'^FS':CRLF$	;* Code 39
END

* * * * * * *
* 2nd Block Right - Revision Level & Delivery Location
* * * * * * *

IF RevLvl NE '' THEN
	LabelString := '^FO615,233^A0,25^FDRev.Lvl:^FS':CRLF$			;* Label Line 1
	LabelString := '^FO615,263^A0,25^FD(2P)^FS':CRLF$				;* Label Line 2
	LabelString := '^FO720,233^A0,60,48^FD':RevLvl:'^FS':CRLF$		;* Readable
	LabelString := '^FO830,203^B3,,100,N^FD2P':RevLvl:'^FS':CRLF$	;* Code 39
END

LabelString := '^FO615,308^A0,25^FDDLOC^FS':CRLF$					;* Label Line 1
LabelString := '^FO700,308^A0,120,80^FD':DeliveryLoc:'^FS':CRLF$	;* Readable


* * * * * * *
* 3rd Block Left - Serial Number
* * * * * * *

LabelString := '^FO0,408^A0,25^FDSerial #:^FS':CRLF$				;* Label Line 1
LabelString := '^FO0,438^A0,25^FD(3S)^FS':CRLF$						;* Label Line 2
LabelString := '^FO100,408^A0,120,80^FD':SerialNo:'^FS':CRLF$		;* Readable
LabelString := '^FO50,503^BY2^B3,,90,N^FD3S':SerialNo:'^FS':CRLF$	;* Code 39 2 dot bar
LabelString := '^BY3':CRLF$											;* Reset to 3 dot bar


* * * * * * *
* 3rd Block Right - Plant/Dock, Storage Bin, Plant Name, Plant City & Lot #
* * * * * * *

LabelString := '^FO615,428^A0,25^FDPLT./DOCK^FS':CRLF$			;* Label Line 1
LabelString := '^FO615,453^A0,100,80^FD':PlantDock:'^FS':CRLF$	;* Readable

LabelString := '^FO850,408^BY2^BC,40,N^FD1T':LotNo:'^FS':CRLF$		;* Code 128
LabelString := '^BY3':CRLF$
LabelString := '^FO900,453^A0,25^FDLOT NO:^FS':CRLF$
LabelString := '^FO900,478^A0,25^FD(1T)^FS':CRLF$
LabelString := '^FO1000,453^A030,40^FD':LotNo:'^FS':CRLF$

IF StorageBin NE '' THEN
	LabelString := '^FO615,534^A0,25^FDSTORAGE BIN:^FS':CRLF$		;* Storage Bin Label
	LabelString := '^FO775,534^A0,25^FD':StorageBin:'^FS':CRLF$		;* Storage Bin Readable
END

IF PlantName NE '' THEN
	LabelString := '^FO615,559^A0,25^FDPLANT NAME:^FS':CRLF$		;* Plant Name Label
	LabelString := '^FO775,559^A0,25^FD':PlantName:'^FS':CRLF$		;* Plant Name Readable
END

IF PlantCity NE '' THEN
	LabelString := '^FO615,584^A0,25^FDPLANT CITY:^FS':CRLF$		;* Plant City Label
	LabelString := '^FO775,584^A0,25^FD':PlantCity:'^FS':CRLF$		;* Plant City Readable
END

* * * * * * *
* 4th Block Left - 
* * * * * * *

LabelString := '^FO20,612^XGR:ATMIHorz,1,1^FS':CRLF$			;* ATMI Logo

LabelString:= '^FO0,700^A050,35^FDCarton: ':CartonNo:' of ':CartonQty:'^FS':CRLF$

* * * * * * *
* 4th Block Right - Supplier and Description info
* * * * * * *

* Supplier  Code

LabelString := '^FO620,660^A0,25^FDSupplier (V):^FS':CRLF$				;* Label Line 1
LabelString := '^FO780,660^A0,45,30^FD':SupplierCd:'^FS':CRLF$			;* Readable
LabelString := '^FO650,606^BY2^B3,,50,N^FDV':SupplierCd:'^FS':CRLF$		;* Code 39
LabelString := '^BY3'

* Part Description

LabelString := '^FO620,700^A0,40,30^FDDesc: ':PartDesc:'^FS':CRLF$

* Manufacture Date

LabelString := '^FO1060,690^A0,25,28^FDMfg.Date:^FS':CRLF$
LabelString := '^FO1060,715^A0,25,28^FD':MfgDt:'^FS':CRLF$

* Manufacturer Name, City, ST, ZIP

LabelString := '^FO620,743^A0,25,28^FD':Manufacturer:'^FS':CRLF$
LabelString := '^FO620,768^A0,25,28^FD':City:' ':ST:' ':ZIP:'^FS'

* Country (Made In)

LabelString := '^FO1060,743^A0,25,28^FDMade In:^FS':CRLF$
LabelString := '^FO1060,768^A0,25,28^FD':Country:'^FS':CRLF$

LabelString := '^XZ'

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

GOSUB OIPrint_Err

RETURN


* * * * * * *
MasterLabel:
* * * * * * *

CustPartNo		= Parms[1,@RM]			;* Customer Part No				- 18 alphanumeric
PartQty			= Parms[COL2()+1,@RM]	;* Part Qty 					- 6  numeric
SupplierCd		= Parms[COL2()+1,@RM]	;* Customer supplied Vend ID	- 12 alphanumeric
DeliveryLoc		= Parms[COL2()+1,@RM]	;* Delivery Location			- 8  char (VARIOUS is OK)
SerialNo		= Parms[COL2()+1,@RM]	;* EDI transaction serial no	- 9  alpha 

PlantDock		= Parms[COL2()+1,@RM]	;* Plant & Dock designator		- 7  character
StorageBin		= Parms[COL2()+1,@RM]	;* Storage Bin at Customer		- 30 character
PlantName		= Parms[COL2()+1,@RM]	;* Ship to Plant Name			- 30 character
PlantCity		= Parms[COL2()+1,@RM]	;* Ship to Plant City			- 30 character
ShipDt			= Parms[COL2()+1,@RM]	;* Ship Date					- MM/DD/YYYY
PartDesc		= Parms[COL2()+1,@RM]	;* Part Description				- 25 character

* optional parms

Manufacturer	= Parms[COL2()+1,@RM]	;* Manufacturer					- 30 character
City			= Parms[COL2()+1,@RM]	;* Mfr City						- 20 character
ST				= Parms[COL2()+1,@RM]	;* Mfr State code				- 2  character
ZIP				= Parms[COL2()+1,@RM]	;* ZIP code						- 7  character
Country			= Parms[COL2()+1,@RM]	;* Country of origin			- 10 character

IF CustPartNo	= '' THEN ErrorMsg = ErrTitle:@SVM:'Null parm CustPartNo passed to routine (':Method:').'
IF PartQty		= '' THEN ErrorMsg = ErrTitle:@SVM:'Null parm PartQty passed to routine (':Method:').'
IF SupplierCd	= '' THEN ErrorMsg = ErrTitle:@SVM:'Null parm SupplierCd passed to routine (':Method:').'
IF ShipDt		= '' THEN ErrorMsg = ErrTitle:@SVM:'Null parm ShipDate passed to routine (':Method:').'
IF PartDesc		= '' THEN ErrorMsg = ErrTitle:@SVM:'Null parm PartDesc passed to routine (':Method:').'

* Null defaults for shipper info

IF Manufacturer	= '' THEN Manufacturer	= obj_Install('Get_Prop','CompAddr')
IF City			= '' THEN City			= obj_Install('Get_Prop','City')
IF ST			= '' THEN ST			= obj_Install('Get_Prop','State')
IF ZIP			= '' THEN ZIP			= obj_Install('Get_Prop','ZIPShort')
IF Country		= '' THEN Country		= obj_Install('Get_Prop','Country')

IF ErrorMsg NE '' THEN
	Set_Status(-1,'',ErrorMsg)
	RETURN
END

*Start Printing Process

GOSUB OIPIInit	;* Selects printer and initializes OIPrinter Interface
GOSUB Label6x4	;* Zebra printer setup and background lines for labels 

* * * * * * *
* Top Block Left - Customer Part Number
* * * * * * *

LabelString := '^FO230,0^FR^GB800,0,50,B^FS':CRLF$				;* Black background for title 
LabelString := '^FO270,5,^A0,45,120^FR^FDMASTER LOAD ^FS':CRLF$

LabelString := '^BY2':CRLF$						;* This is Code 128 Barcode - change ratio

LabelString := '^FO0,0^A0,25^FDPart #:^FS':CRLF$					;* Label Line 1
LabelString := '^FO0,30^A0,25^FDCust(P)^FS':CRLF$					;* Label Line 2
LabelString := '^FO100,55^A0,60^FD':CustPartNo:'^FS':CRLF$			;* Readable
LabelString := '^FO100,100^BC,100,N^FDP':CustPartNo:'^FS':CRLF$		;* Code 128

LabelString := '^BY3,3.0':CRLF$					;* Reset narrow bar width and Ratio

* * * * * * *
* Top Block Right - Quantity
* * * * * * *

LabelString := '^FO700,155^A0,25^FDQuantity:^FS':CRLF$			;* Label Line 1
LabelString := '^FO700,180^A0,25^FD(Q)^FS':CRLF$				;* Label Line 2
LabelString := '^FO810,150^A0,60,70^FD':PartQty:'^FS':CRLF$		;* Readable
LabelString := '^FO700,50^B3,,100,N^FDQ':PartQty:'^FS':CRLF$	;* Code 39

* * * * * * *
* 2nd Block Left - Supplier Code
* * * * * * *

LabelString := '^FO0,208^A0,25^FDSupplier:^FS':CRLF$				;* Label Line 1
LabelString := '^FO0,238^A0,25^FD(V)^FS':CRLF$						;* Label Line 2
LabelString := '^FO100,208^A0,120,80^FD':SupplierCd:'^FS':CRLF$		;* Readable

LabelString := '^FO100,303^BY2^B3,,90,N^FDV':SupplierCd:'^FS':CRLF$	;* Code 39 - 2 dot bar
LabelString := '^BY3':CRLF$											;* Reset to 3 dot bar


* * * * * * *
* 2nd Block Right - Delivery Location
* * * * * * *

LabelString := '^FO615,208^A0,25^FDDLOC^FS':CRLF$					;* Label Line 1
LabelString := '^FO665,258^A0,120,80^FD':DeliveryLoc:'^FS':CRLF$	;* Readable



* * * * * * *
* 3rd Block Left - Serial Number
* * * * * * *

LabelString := '^FO0,408^A0,25^FDSerial #:^FS':CRLF$				;* Label Line 1
LabelString := '^FO0,438^A0,25^FD(4S)^FS':CRLF$						;* Label Line 2
LabelString := '^FO100,408^A0,120,80^FD':SerialNo:'^FS':CRLF$		;* Readable
LabelString := '^FO50,503^BY2^B3,,90,N^FD4S':SerialNo:'^FS':CRLF$	;* Code 39 2 dot bar
LabelString := '^BY3':CRLF$											;* Reset to 3 dot bar


* * * * * * *
* 3rd Block Right - Plant & Dock, Bin, Plant Name and Plant City
* * * * * * *

LabelString := '^FO615,408^A0,25^FDPLT.DOC^FS':CRLF$			;* Label Line 1
LabelString := '^FO775,408^A0,120,80^FD':PlantDock:'^FS':CRLF$	;* Readable

IF StorageBin NE '' THEN
	LabelString := '^FO615,508^A0,25^FDStorage Bin:^FS':CRLF$		;* Storage Bin Label
	LabelString := '^FO775,508^A0,25^FD':StorageBin:'^FS':CRLF$		;* Storage Bin Readable
END

IF PlantName NE '' THEN
	LabelString := '^FO615,542^A0,25^FDPlant Name:^FS':CRLF$		;* Plant Name Label
	LabelString := '^FO775,542^A0,25^FD':PlantName:'^FS':CRLF$		;* Plant Name Readable
END

IF PlantCity NE '' THEN
	LabelString := '^FO615,576^A0,25^FDPlant City:^FS':CRLF$		;* Plant City Label
	LabelString := '^FO775,576^A0,25^FD':PlantCity:'^FS':CRLF$		;* Plant City Readable
END

* * * * * * *
* 4th Block Left - 
* * * * * * *

LabelString := '^FO20,612^XGR:':GRFName:',1,1^FS'			;* ATMI Logo


* * * * * * *
* 4th Block Right - Supplier and Description info
* * * * * * *

* Ship Date

LabelString := '^FO615,612^A0,25,28^FDShip Date:^FS'
LabelString := '^FO815,612^A0,65^FD':ShipDt:'^FS'

* Part Description

LabelString := '^FO620,670^A0,40,30^FDDesc: ':PartDesc:'^FS':CRLF$

* Manufacturer Name, City, ST, ZIP

LabelString := '^FO620,720^A0,50,28^FD':Manufacturer:'^FS'
LabelString := '^FO620,768^A0,25,28^FD':City:' ':ST:' ':ZIP:'^FS'

* Country (Made In)

LabelString := '^FO1060,743^A0,25,28^FDMade In:^FS'
LabelString := '^FO1060,768^A0,25,28^FD':Country:'^FS'

LabelString := '^XZ'

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

GOSUB OIPrint_Err

RETURN


* * * * * * *
MixedLoadLabel:
* * * * * * *

SupplierCd		= Parms[1,@RM]			;* Customer supplied Vend ID	- 12 alphanumeric
ShipToName		= Parms[COL2()+1,@RM]	;* Customer ship to Name		- 25 alphanumeric
ShipToAddr		= Parms[COL2()+1,@RM]	;* Customer ship to Address		- 25 alphanumeric
ShipToCity		= Parms[COL2()+1,@RM]	;* Customer ship to City		- 20 alphanumeric
ShipToST		= Parms[COL2()+1,@RM]	;* Customer ship to State		- 2  alpha
ShipToZIP		= Parms[COL2()+1,@RM]	;* Customer ship to ZIP			- 7  alphanumeric
SerialNo		= Parms[COL2()+1,@RM]	;* EDI transaction serial no	- 9  alpha 
PlantDock		= Parms[COL2()+1,@RM]	;* Plant & Dock designator		- 7  character
StorageBin		= Parms[COL2()+1,@RM]	;* Storage Bin at Customer		- 30 character
PlantName		= Parms[COL2()+1,@RM]	;* Ship to Plant Name			- 30 character
PlantCity		= Parms[COL2()+1,@RM]	;* Ship to Plant City			- 30 character
ShipDt			= Parms[COL2()+1,@RM]	;* Ship Date					- MM/DD/YYYY
Manufacturer	= Parms[COL2()+1,@RM]	;* Manufacturer					- 30 character
City			= Parms[COL2()+1,@RM]	;* Mfr City						- 20 character
ST				= Parms[COL2()+1,@RM]	;* Mfr State code				- 2  character
ZIP				= Parms[COL2()+1,@RM]	;* ZIP code						- 7  character
PartNos			= Parms[COL2()+1,@RM]	;* Customer Part No(s)			- 18 alphanumeric
PartQtys		= Parms[COL2()+1,@RM]	;* Part Qty(s) 					- 6  numeric

IF SupplierCd	= ''	THEN ErrorMsg = 'Null parm SupplierCd passed to routine (':Method:').'
IF LEN(SupplierCd) > 12	THEN ErrorMsg = 'Supplier Code exceeds 12 characters (':Method:').'
IF LEN(SerialNo) > 9 	THEN ErrorMsg = 'Supplier Code exceeds 9 characters (':Method:').'

* Null defaults for shipper info

IF Manufacturer	= '' THEN Manufacturer	= obj_Install('Get_Prop','CompAddr')
IF City			= '' THEN City			= obj_Install('Get_Prop','City')
IF ST			= '' THEN ST			= obj_Install('Get_Prop','State')
IF ZIP			= '' THEN ZIP			= obj_Install('Get_Prop','ZIPShort')


*Start Printing Process

GOSUB OIPIInit	;* Selects printer and initializes OIPrinter Interface
GOSUB Label6x4	;* Zebra printer setup and background lines for labels 

* * * * * * *
* Top Block 
* * * * * * *

LabelString := '^FO10,0^FR^GB1180,0,190,B^FS':CRLF$				;* Black background for title 
LabelString := '^FO20,5,^A0,220,220^FR^FDMIXED LOAD^FS':CRLF$

* * * * * * *
* 2nd Block Left - Supplier Code
* * * * * * *

LabelString := '^FO0,208^A0,25^FDSupplier:^FS':CRLF$				;* Label Line 1
LabelString := '^FO0,238^A0,25^FD(V)^FS':CRLF$						;* Label Line 2
LabelString := '^FO100,208^A0,120,80^FD':SupplierCd:'^FS':CRLF$		;* Readable

LabelString := '^FO100,303^BY2^B3,,90,N^FDV':SupplierCd:'^FS':CRLF$	;* Code 39 - 2 dot bar
LabelString := '^BY3':CRLF$											;* Reset to 3 dot bar


* * * * * * *
* 2nd Block Right - Ship to Address
* * * * * * *

LabelString := '^FO615,208^A0,25^FDShip To:^FS':CRLF$				;* Label Line 1
LabelString := '^FO630,240^A0,45,30^FD':ShipToName:'^FS':CRLF$
LabelString := '^FO630,290^A0,45,30^FD':ShipToAddr:'^FS':CRLF$
LabelString := '^FO630,340^A0,45,30^FD':ShipToCity:' ':ShipToST:' ':ShipToZIP:'^FS':CRLF$

* * * * * * *
* 3rd Block Left - Serial Number
* * * * * * *

LabelString := '^FO0,408^A0,25^FDSerial #:^FS':CRLF$				;* Label Line 1
LabelString := '^FO0,438^A0,25^FD(5S)^FS':CRLF$						;* Label Line 2
LabelString := '^FO100,408^A0,120,80^FD':SerialNo:'^FS':CRLF$		;* Readable
LabelString := '^FO50,503^BY2^B3,,90,N^FD5S':SerialNo:'^FS':CRLF$	;* Code 39 2 dot bar
LabelString := '^BY3':CRLF$											;* Reset to 3 dot bar


* * * * * * *
* 3rd Block Right - Plant & Dock, Bin, Plant Name and Plant City
* * * * * * *

LabelString := '^FO615,408^A0,25^FDPLT.DOC^FS':CRLF$			;* Label Line 1
LabelString := '^FO775,408^A0,120,80^FD':PlantDock:'^FS':CRLF$	;* Readable

IF StorageBin NE '' THEN
	LabelString := '^FO615,508^A0,25^FDStorage Bin:^FS':CRLF$		;* Storage Bin Label
	LabelString := '^FO775,508^A0,25^FD':StorageBin:'^FS':CRLF$		;* Storage Bin Readable
END

IF PlantName NE '' THEN
	LabelString := '^FO615,542^A0,25^FDPlant Name:^FS':CRLF$		;* Plant Name Label
	LabelString := '^FO775,542^A0,25^FD':PlantName:'^FS':CRLF$		;* Plant Name Readable
END

IF PlantCity NE '' THEN
	LabelString := '^FO615,576^A0,25^FDPlant City:^FS':CRLF$		;* Plant City Label
	LabelString := '^FO775,576^A0,25^FD':PlantCity:'^FS':CRLF$		;* Plant City Readable
END

* * * * * * *
* 4th Block Left - 
* * * * * * *

LabelString := '^FO20,612^XGR:':GRFName:',1,1^FS':CRLF$			;* Company Logo


* * * * * * *
* 4th Block Right - Supplier and Description info
* * * * * * *

* Ship Date

LabelString := '^FO615,612^A0,27,20^FDShip Date:^FS':CRLF$
LabelString := '^FO815,612^A0,65^FD':ShipDt:'^FS':CRLF$

* Manufacturer Name, City, ST, ZIP

LabelString := '^FO620,680^A0,45,30^FD':Manufacturer:'^FS':CRLF$
LabelString := '^FO620,730^A0,45,30^FD':City:' ':ST:' ':ZIP:'^FS':CRLF$


LabelString := '^XZ':CRLF$


TopLabel = LabelString	;* End of top label


PartCnt = COUNT(PartNos,@VM) + (PartNos NE '')

* Put 6 part number / qty pairs on the second label

LabelString  = '^XA'				;* Start of label format
LabelString := '^LH10,30'			;* Label home offset (needed to get onto the label medium)
LabelString := '^BY3'				;* Set narrow Bar Code line width to 3 dots
LabelString := '^PR2'				;* Print speed = 2 IPS
LabelString := '^LL812.8':CRLF$		;* Label Length in Dots @ 8 Dots per Inch

FOR I = 1 TO 6
	IF PartNos<1,I> NE '' THEN
		YSpacer = (I - 1) * 135
		Y1 = 0 + YSpacer
		Y2 = 30 + YSpacer
		Y3 = 60 + YSpacer
		Y4 = 75 + YSpacer
		Y5 = 105 + YSpacer
		Y6 = 0 + YSpacer
		S1 = 130 + YSpacer
		
		IF I < 6 THEN
			LabelString := '^FO0,':S1:'^GB1200,0,3,B^FS':CRLF$	;* horizontal line under fields
		END
		
		LabelString := '^BY2':CRLF$						;* This is Code 128 Barcode - change ratio

		LabelString := '^FO0,':Y1:'^A0,25^FDPart #:^FS':CRLF$					;* Label Line 1
		LabelString := '^FO0,':Y2:'^A0,25^FDCust(P)^FS':CRLF$					;* Label Line 2
		LabelString := '^FO100,':Y1:'^A0,63,45^FD':PartNos<1,I>:'^FS':CRLF$		;* Readable
		LabelString := '^FO100,':Y3:'^BC,65,N^FDP':PartNos<1,I>:'^FS':CRLF$		;* Code 128

		LabelString := '^BY3,3.0':CRLF$					;* Reset narrow bar width and Ratio

		LabelString := '^FO700,':Y4:'^A0,25^FDQuantity:^FS':CRLF$				;* Label Line 1
		LabelString := '^FO700,':Y5:'^A0,25^FD(Q)^FS':CRLF$						;* Label Line 2
		LabelString := '^FO810,':Y4:'^A0,63,45^FD':PartQtys<1,I>:'^FS':CRLF$	;* Readable
		LabelString := '^FO700,':Y6:'^B3,,65,N^FDQ':PartQtys<1,I>:'^FS':CRLF$	;* Code 39
	END
NEXT I

LabelString := '^XZ':CRLF$
SecondLabel = LabelString
ThirdLabel = ''

IF PartCnt > 6 THEN

	* Put 6 more part number / qty pairs on the third

	LabelString  = '^XA'				;* Start of label format
	LabelString := '^LH10,30'			;* Label home offset (needed to get onto the label medium)
	LabelString := '^BY3'				;* Set narrow Bar Code line width to 3 dots
	LabelString := '^PR2'				;* Print speed = 2 IPS
	LabelString := '^LL812.8':CRLF$		;* Label Length in Dots @ 8 Dots per Inch

	FOR I = 7 TO 12
		IF PartNos<1,I> NE '' THEN
			YSpacer = ((I-6) - 1) * 135
			Y1 = 0 + YSpacer
			Y2 = 30 + YSpacer
			Y3 = 60 + YSpacer
			Y4 = 75 + YSpacer
			Y5 = 105 + YSpacer
			Y6 = 0 + YSpacer
			S1 = 130 + YSpacer
			
			IF I < 12 THEN
				LabelString := '^FO0,':S1:'^GB1200,0,3,B^FS':CRLF$	;* horizontal line under fields
			END
			
			LabelString := '^BY2':CRLF$						;* This is Code 128 Barcode - change ratio

			LabelString := '^FO0,':Y1:'^A0,25^FDPart #:^FS':CRLF$					;* Label Line 1
			LabelString := '^FO0,':Y2:'^A0,25^FDCust(P)^FS':CRLF$					;* Label Line 2
			LabelString := '^FO100,':Y1:'^A0,63,45^FD':PartNos<1,I>:'^FS':CRLF$		;* Readable
			LabelString := '^FO100,':Y3:'^BC,65,N^FDP':PartNos<1,I>:'^FS':CRLF$		;* Code 128

			LabelString := '^BY3,3.0':CRLF$					;* Reset narrow bar width and Ratio

			LabelString := '^FO700,':Y4:'^A0,25^FDQuantity:^FS':CRLF$				;* Label Line 1
			LabelString := '^FO700,':Y5:'^A0,25^FD(Q)^FS':CRLF$						;* Label Line 2
			LabelString := '^FO810,':Y4:'^A0,63,45^FD':PartQtys<1,I>:'^FS':CRLF$	;* Readable
			LabelString := '^FO700,':Y6:'^B3,,65,N^FDQ':PartQtys<1,I>:'^FS':CRLF$	;* Code 39
		END
	NEXT I

	LabelString := '^XZ':CRLF$
	ThirdLabel = LabelString

END	;* End of check for 7 or more part numbers

IF ThirdLabel NE '' THEN
    If Environment_Services('GetLabelPrintMethod') _EQC 'OIPI' then
        stat = Set_Printer('TEXT',ThirdLabel:SecondLabel:TopLabel)
    end else
        stat = Direct_Print('PRINT', ThirdLabel:SecondLabel:TopLabel)
    end
END ELSE
    If Environment_Services('GetLabelPrintMethod') _EQC 'OIPI' then
        stat = Set_Printer('TEXT',SecondLabel:TopLabel)
    end else
        stat = Direct_Print('PRINT', SecondLabel:TopLabel)
    end
END
GOSUB OIPrint_Err

RETURN


* * * * * * * * * * * * * * * * * * * * * * * *
* L O C A L   M E T H O D S
* * * * * * * * * * * * * * * * * * * * * * * *

* * * * * *
OIPIInit:
* * * * * *

* Internal method that selects printer, initializes OIPI and then prints block grid

FileName 	= "Printing Label"
Title       = "Printing Label"	;* Initialize Printing

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_BR2'			;* Print Server Change
PrinterID = '\\mesirwfp001\MESZBRPRT001'	;* Site specific label printer ID - Skips popup	

PrintPath	= Printer_Select(PrinterID)		;* Select printer - Displays popup if PrinterPort not found 

IF PrintPath = '' THEN
	Def = ""
	Def<MTYPE$> = "TA3"
	Def<MTEXT$> = 'Destination Printer not Selected..'
	Def<MCAPTION$> = ''
	Def<MICON$> = '*'
	Msg(@WINDOW, Def, '')
	RETURN
END

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 GOSUB OIPrint_Err

RETURN


* * * * * * *
Label6x4:
* * * * * * *

BitMap = obj_Install('Get_Prop','ZebraGRF')		;* Substitute company logo converted to .GRF (Zebra graphics format)
OSREAD ImageData FROM BitMap ELSE
	ErrMsg('Unable to Read ':BitMap:' graphic in obj_Zebra160S.')
END
GRFName = FIELD(BitMap,'.',1)


* Label is 1218 x 812 dots at 8dots/mm (203 dots/inch)
* Leave periodic spaces in Label String - OIPrint interface wraps text on spaces and will cut off 
* the LabelString if there aren't any spaces.  Printer Width needs to be set to 132 or greater

LabelString  = '^XA'				;* Start of label format
LabelString := '^LH10,30'			;* Label home offset (needed to get onto the label medium)
LabelString := '^BY3'				;* Set narrow Bar Code line width to 3 dots
LabelString := '^PR2'				;* Print speed = 2 IPS
LabelString := '^LL812.8':CRLF$		;* Label Length in Dots @ 8 Dots per Inch

LabelString := '^FO0,200^GB1200,0,3,B^FS':CRLF$	;* 1st horizontal line (bottom of 1st cell)
LabelString := '^FO0,403^GB1200,0,3,B^FS':CRLF$	;* 2nd horizontal line (bottom of 2nd cell)
LabelString := '^FO0,606^GB1200,0,3,B^FS':CRLF$	;* 3rd horizontal line (bottom of 3rd cell)
LabelString := '^FO606,200^GB0,606,3,B^FS':CRLF$	;* Middle vertical line

RETURN


* * * * * * *
OIPrint_Err:
* * * * * * *

* Local method to terminate print job

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

* Added after upgrade to OI4.13a to reset default printer in OIPI32 engine.

PrintCount	= PrintSetup(PRN_GET$,'',Printers,DefaultPrinter)
CONVERT ',' TO @FM IN DefaultPrinter
DefPrintPath = DefaultPrinter<1>:@FM:DefaultPrinter<3>

Void = set_printer( 'INIT', '', '', .63:@fm:.63:@fm:.25:@fm:'', 0,'',DefPrintPath )
Void = Set_Printer('TERM')


RETURN


