COMPILE FUNCTION obj_React_Item(Method,Parms)

/*
	Methods for React_Item table
    
	01/13/2014 JCH - Initial Coding
     
    Properties:
     
    Methods:
    
    Install(RINo,ReactNo,DTM,ReactHrs,ReactWfrs,RL_Id)				;* Adds Reactor Installation line item to record
	Remove(RINo,ReactNo,DTM,ReactHrs,ReactWfrs,RL_Id,RDSWfrCnt)		;* Adds Removal information to Reactor Installation line item
	
*/


DECLARE FUNCTION Get_Status, Msg, Utility, obj_Tables, Send_Dyn, obj_Popup, obj_React_Item_Hist, obj_React_Item
DECLARE FUNCTION Printer_Select, Set_Printer, obj_Install, Direct_Print, Environment_Services
DECLARE SUBROUTINE  Set_Status, Msg, obj_Tables, Send_Dyn, Direct_Print
DECLARE SUBROUTINE ErrMsg, Btree.Extract

$INSERT MSG_EQUATES
$INSERT REACT_ITEM_EQUATES
$INSERT REACT_ITEM_HIST_EQUATES
$INSERT REACTOR_EQUATES
$INSERT REACT_READS_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



EQU CRLF$	TO \0D0A\
EQU TAB$	TO CHAR(9)


ErrTitle = 'Error in Stored Procedure "obj_ReactItem"'
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

Result = ''

BEGIN CASE
	
	CASE Method = 'CurrStatus'		; GOSUB CurrStatus
	CASE Method = 'ServiceHrs'		; GOSUB ServiceHrs
	CASE Method = 'ServiceWfrs'		; GOSUB ServiceWfrs
	CASE Method = 'Serial_RINo'		; GOSUB Serial_RINo
	CASE Method = 'ReactWfrCnt'		; GOSUB ReactWfrCnt
	CASE Method = 'ReactHrs'		; GOSUB ReactHrs
	CASE Method = 'CalcDesc'		; GOSUB CalcDesc
	CASE Method = 'PrintLabel'		; GOSUB PrintLabel
	
	CASE 1
		ErrorMsg = 'Unknown Method ':QUOTE(Method):' passed to routine.'

END CASE

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

RETURN Result


* * * * * * *
CurrStatus:
* * * * * * *

IF NOT(ASSIGNED(RINo))			THEN RINo			= Parms[1,@RM]
IF NOT(ASSIGNED(ReactItemRec))	THEN ReactItemRec	= Parms[COL2()+1,@RM]

IF RINo = '' THEN RETURN			;* This is used in the dictionary -> don't throw an error for a null parmeter

IF ReactItemRec = '' THEN ReactItemRec = XLATE('REACT_ITEM',RINo,'','X')

Parms = '':@RM:RINo:@RM:''
HistKeys = obj_React_Item_Hist('GetHistory',Parms)  ;* 3 parameters RINo is the middle one
HistKey = HistKeys<1,1>								;* This is the most recent 

LastInstallRec = XLATE('REACT_ITEM_HIST',HistKeys<1,1>,'','X')

InstDTM		= FIELD(HistKey,'*',3)
RemDTM		= LastInstallRec<REACT_ITEM_HIST_REM_DTM$>

RetireDt	= ReactItemRec<REACT_ITEM_RETIRE_DT$>
Notes 		= ReactItemRec<REACT_ITEM_NOTES$>

CONVERT @LOWER_CASE TO @UPPER_CASE IN NOtes


BEGIN CASE
	CASE RetireDt NE ''													; Result = 'R'
	CASE InstDTM NE '' AND RemDTM = ''									; Result = 'I'
	CASE InstDTM NE '' AND RemDTM NE '' OR INDEX(Notes,'USED',1)		; Result = 'U'
	CASE InstDTM = '' AND RemDTM = ''									; Result = 'N'
	CASE 1																; Result = '?'
END CASE
		
RETURN


* * * * * * *
ServiceHrs:
* * * * * * *

IF NOT(ASSIGNED(RINo))			THEN RINo			= Parms[1,@RM]
IF NOT(ASSIGNED(ReactItemRec))	THEN ReactItemRec	= Parms[COL2()+1,@RM]

IF RINo = '' THEN RETURN			;* This is used in the dictionary -> don't throw an error for a null parmeter

IF ReactItemRec = '' THEN ReactItemRec = XLATE('REACT_ITEM',RINo,'','X')

LastRemDtm = ReactItemRec<REACT_ITEM_REM_DTM$,1>

IF LastRemDTM = '' THEN 
	ReactNo = ReactItemRec<REACT_ITEM_REACT_NO$,1>
	LastReadDTM = XLATE('REACTOR',ReactNo,REACTOR_LAST_READ_HRS_DTM$,'X')
	LastReadHrs = XLATE('REACT_READS',ReactNo:'*':LastReadDTM,REACT_READS_HOURS$,'X')
END ELSE
	LastReadHrs = ''
END

Ans = ''

IRCnt = COUNT(ReactItemRec<REACT_ITEM_INST_REACT_HRS$>,@VM) + (ReactItemRec<REACT_ITEM_INST_REACT_HRS$> NE '')

FOR I = 1 TO IRCnt

	RemReactHrs = ReactItemRec<REACT_ITEM_REM_REACT_HRS$,I>
	InstReactHrs = ReactItemRec<REACT_ITEM_INST_REACT_HRS$,I>
	
	IF I = 1 AND LastReadHrs NE '' THEN
		ReactNo = ReactItemRec<REACT_ITEM_REACT_NO$,I>

		LastReadDTM = XLATE('REACTOR',ReactNo,25,'X')
		LastReadHrs = XLATE('REACT_READS',ReactNo:'*':LastReadDTM,1,'X')
	
		RemReactHrs = LastReadHrs
	END
	
	IF RemReactHrs > InstReactHrs AND NUM(InstReactHrs) AND NUM(RemReactHrs) THEN
		Ans<1,I> = RemReactHrs - InstReactHrs
	END ELSE
		Ans<1,I> = ''
	END
NEXT I

Result = Ans

RETURN


* * * * * * *
ServiceWfrs:
* * * * * * *

IF NOT(ASSIGNED(RINo))			THEN RINo			= Parms[1,@RM]
IF NOT(ASSIGNED(ReactItemRec))	THEN ReactItemRec	= Parms[COL2()+1,@RM]

IF RINo = '' THEN RETURN			;* This is used in the dictionary -> don't throw an error for a null parmeter

IF ReactItemRec = '' THEN ReactItemRec = XLATE('REACT_ITEM',RINo,'','X')

LastRemDtm = ReactItemRec<REACT_ITEM_REM_DTM$,1>

IF LastRemDTM = '' THEN 
	ReactNo 		= ReactItemRec<REACT_ITEM_REACT_NO$,1>
	LastReadDTM		= XLATE('REACTOR',ReactNo,REACTOR_LAST_READ_WFRS_DTM$,'X')
	LastReadWfrs	= XLATE('REACT_READS',ReactNo:'*':LastReadDTM,REACT_READS_WAFER_CNT$,'X')
END ELSE
	LastReadWfrs = ''
END

Ans = ''

IRCnt = COUNT(ReactItemRec<REACT_ITEM_INST_REACT_WFRS$>,@VM) + (ReactItemRec<REACT_ITEM_INST_REACT_WFRS$> NE '')


IF IRCnt = 0 THEN
	Ans = LastReadWfrs
END ELSE

	FOR I = 1 TO IRCnt

		RemReactWfrs = ReactItemRec<REACT_ITEM_REM_REACT_WFRS$,I>
		InstReactWfrs = ReactItemRec<REACT_ITEM_INST_REACT_WFRS$,I>
		
		IF I = 1 AND LastReadWfrs NE '' THEN
			RemReactWfrs = LastReadWfrs
		END
		
		IF RemReactWfrs > InstReactWfrs AND NUM(InstReactWfrs) AND NUM(RemReactWfrs) THEN
			Ans<1,I> = RemReactWfrs - InstReactWfrs
		END ELSE
			Ans<1,I> = ''
		END
		
	NEXT I
END

Result = Ans

RETURN Result


* * * * * * *
Serial_RINo:
* * * * * * * 

* Temporary for conversion

SerialNos = Parms[1,@RM]

IF SerialNos = '' THEN RETURN

OPEN 'DICT.REACT_ITEM' TO DictReactItem ELSE
	
	RETURN
END

snCnt = COUNT(SerialNos,@VM) + (SerialNos NE '')

FOR I = 1 TO snCnt
	SerialNo = SerialNos<1,I>
	IF SerialNo NE '' THEN
	
		IF RowExists('REACT_ITEM',SerialNo) THEN
			RINo = SerialNo
		END ELSE
			SearchString = 'SERIAL':@VM:SerialNo:@FM

			Option = ''
			Flag = ''

			Btree.Extract(SearchString,'REACT_ITEM',DictReactItem,RINo,Option,Flag)

			IF INDEX(RINo,@VM,1) THEN RINo = FIELD(RINo,@VM,1,3)
		END
		
		Result<1,I> = RINo
	END	;* End of check for null SerialNo
NEXT I

RETURN


* * * * * * *
ServicePCRC:
* * * * * * *

IF NOT(ASSIGNED(RINo))			THEN RINo			= Parms[1,@RM]
IF NOT(ASSIGNED(ReactItemRec))	THEN ReactItemRec	= Parms[COL2()+1,@RM]

IF RINo = '' THEN RETURN		;* This is used in the dictionary -> don't throw an error for a null parmeter

IF ReactItemRec = '' THEN ReactItemRec = XLATE('REACT_ITEM',RINo,'','X')

LastRemDtm = ReactItemRec<REACT_ITEM_REM_DTM$,1>

IF LastRemDTM = '' THEN 
	ReactNo 		= ReactItemRec<REACT_ITEM_REACT_NO$,1>
	LastReadDTM 	= XLATE('REACTOR',ReactNo,REACTOR_LAST_READ_WFRS_DTM$,'X')
	LastReadWfrs 	= XLATE('REACT_READS',ReactNo:'*':LastReadDTM,REACT_READS_WAFER_CNT$,'X')
END ELSE
	LastReadWfrs = ''
END

Ans = ''

IRCnt = COUNT(ReactItemRec<REACT_ITEM_INST_REACT_WFRS$>,@VM) + (ReactItemRec<REACT_ITEM_INST_REACT_WFRS$> NE '')

IF IRCnt = 0 THEN
	Ans = LastReadWfrs
END ELSE
	FOR I = 1 TO IRCnt

		RemReactWfrs	= ReactItemRec<REACT_ITEM_REM_REACT_WFRS$,I>
		InstReactWfrs	= ReactItemRec<REACT_ITEM_INST_REACT_WFRS$,I>		;* This should always be set to zero
		
		IF I = 1 AND LastReadWfrs NE ''THEN
			RemReactWfrs = LastReadWfrs
		END
		
		IF RemReactWfrs > InstReactWfrs AND NUM(InstReactWfrs) AND NUM(RemReactWfrs) THEN
			Ans<1,I> = RemReactWfrs - InstReactWfrs - ReactItemRec<REACT_ITEM_RDS_WFR_CNT$,I>
		END ELSE
			Ans<1,I> = ''
		END
		
	NEXT I
END

Result = Ans

RETURN


* * * * * * *
ReactWfrCnt:
* * * * * * *

IF NOT(ASSIGNED(RINo))			THEN RINo			= Parms[1,@RM]
IF NOT(ASSIGNED(ReactItemRec))	THEN ReactItemRec	= Parms[COL2()+1,@RM]

IF RINo = '' THEN RETURN		;* This is used in the dictionary -> don't throw an error for a null parmeter

IF ReactItemRec = '' THEN ReactItemRec = XLATE('REACT_ITEM',RINo,'','X')


ReactNos = ReactItemRec<REACT_ITEM_REACT_NO$>

ReactCnt = COUNT(ReactNos,@VM) + (ReactNos NE '')

Ans = ''

FOR I = 1 TO ReactCnt
	ReactNo = ReactNos<1,I>
	InstWfrCnt	= ReactItemRec<REACT_ITEM_INST_REACT_WFRS$,I>
	RemWfrCnt	= ReactItemRec<REACT_ITEM_REM_REACT_WFRS$,I>
	

	IF I = 1 AND RemWfrCnt = '' THEN
		LastReadDTM	= XLATE( 'REACTOR', ReactNo, REACTOR_LAST_READ_WFRS_DTM$, 'X' )
		RemWfrCnt	= XLATE( 'REACT_READS' ,ReactNo:'*':LastReadDTM, REACT_READS_WAFER_CNT$, 'X' )
	END
	
	Delta = ''
	IF InstWfrCnt NE '' THEN
		IF RemWfrCnt NE '' THEN
			IF RemWfrCnt >= InstWfrCnt THEN
				Delta = RemWfrCnt - InstWfrCnt
			END
		END	;* End of check for RemWfrCnt
	END	;* End of check for InstWfrCnt
	
	Ans<1,I> = Delta
	
NEXT I

Result = Ans

RETURN


* * * * * * *
ReactHrs:
* * * * * * *

IF NOT(ASSIGNED(RINo))			THEN RINo			= Parms[1,@RM]
IF NOT(ASSIGNED(ReactItemRec))	THEN ReactItemRec	= Parms[COL2()+1,@RM]

IF RINo = '' THEN RETURN		;* This is used in the dictionary -> don't throw an error for a null parmeter

IF ReactItemRec = '' THEN ReactItemRec = XLATE('REACT_ITEM',RINo,'','X')

ReactNos = ReactItemRec<REACT_ITEM_REACT_NO$>

ReactCnt = COUNT(ReactNos,@VM) + (ReactNos NE '')

Ans = ''

FOR I = 1 TO ReactCnt
	ReactNo = ReactNos<1,I>
	InstHrs	= ReactItemRec<REACT_ITEM_INST_REACT_HRS$,I>
	RemHrs	= ReactItemRec<REACT_ITEM_REM_REACT_HRS$,I>

	IF I = 1 AND RemHrs = '' THEN
		LastReadDTM	= XLATE( 'REACTOR', ReactNo, REACTOR_LAST_READ_HRS_DTM$, 'X' )
		RemHrs		= XLATE( 'REACT_READS' ,ReactNo:'*':LastReadDTM, REACT_READS_HOURS$, 'X' )
	END
	
	Delta = ''
	IF InstHrs NE '' THEN
		IF RemHrs NE '' THEN
			IF RemHrs >= InstHrs THEN
				Delta = RemHrs - InstHrs
			END
		END	;* End of check for RemHrs
	END	;* End of check for InstHrs
	
	Ans<1,I> = Delta
	
NEXT I

Result = Ans

return



* * * * * * *
Serial_GRNo:
* * * * * * * 

* Temporary for conversion

SerialNos = Parms[1,@RM]

IF SerialNos = '' THEN RETURN

OPEN 'DICT.REACT_ITEM' TO DictReactItem ELSE
	
	RETURN
END

snCnt = COUNT(SerialNos,@VM) + (SerialNos NE '')

FOR I = 1 TO snCnt
	SerialNo = SerialNos<1,I>
	IF SerialNo NE '' THEN
		SearchString = 'SERIAL':@VM:SerialNo:@FM

		Option = ''
		Flag = ''

		Btree.Extract(SearchString,'REACT_ITEM',DictReactItem,RINo,Option,Flag)

		IF INDEX(RINo,@VM,1) THEN RINo = FIELD(RINo,@VM,1,3)
		
		Result<1,I> = RINo
	END	;* End of check for null SerialNo
NEXT I



RETURN


* * * * * * *
SplitSerial:
* * * * * * *

PartNo = Parms[1,@RM]


IF PartNo = ''	THEN ErrorMsg = 'Null Parameter "PartNo" passed to routine. (':Method:')'

IF ErrorMsg NE '' THEN RETURN

OPEN 'DICT.REACT_ITEM' TO DictReactItem ELSE
	DEBUG
	RETURN
END

SelectSent	= 'SERIAL':@VM:'[':PartNo:']':@FM
Option		= ''
Flag		= ''

Btree.Extract(SelectSent,'REACT_ITEM',DictReactItem,RINos,Option,Flag)

IF Get_Status(errCode) THEN
	ErrMsg(errCode)
	RETURN
END

grCnt = COUNT(RINos,@VM) + (RINos NE '')

FOR I = 1 TO grCnt
	RINo = RINos<1,I>
	
	otParms = 'REACT_ITEM':@RM:RINo

	ReactItemRec = obj_Tables('ReadRec',otParms)

	Serial = ReactItemRec<REACT_ITEM_SERIAL$>
	
	SWAP PartNo WITH '' IN Serial
	
	*Serial[1,LEN(PartNo)] = ''
	
	IF Serial[1,1] = '-' THEN Serial[1,1] = ''
	
	ReactItemRec<REACT_ITEM_SERIAL_NO$> = Serial
	ReactItemRec<REACT_ITEM_MFR_PART_NO$> = PartNo
		
	otParms = FIELDSTORE(OtParms,@RM,4,0,ReactItemRec)

	obj_Tables('WriteRec',otParms)

NEXT I

Result = RINos

RETURN


* * * * * * *
CalcDesc:
* * * * * * *

IF NOT(ASSIGNED(RINo))			THEN RINo			= Parms[1,@RM]
IF NOT(ASSIGNED(ReactItemRec))	THEN ReactItemRec	= Parms[COL2()+1,@RM]

IF RINo = '' THEN RETURN		;* This is used in the dictionary -> don't throw an error for a null parmeter

IF ReactItemRec = '' THEN ReactItemRec = XLATE('REACT_ITEM',RINo,'','X')

RIType = ReactItemRec<REACT_ITEM_RI_TYPE$>

BEGIN CASE
	CASE RITYpe = 'W'
		CalcDesc = ReactItemRec<REACT_ITEM_DESC$>
		
	CASE RIType = 'A'
		CalcDesc = ReactItemRec<REACT_ITEM_DESC$>
		
	CASE RIType = 'T'
		Desc 		= ReactItemRec<REACT_ITEM_DESC$>
		Style		= ReactItemRec<REACT_ITEM_TUBE_STYLE$>
		Pressure	= ReactItemRec<REACT_ITEM_TUBE_PRESS$>
		
		RITypeDesc	= obj_Popup('CodeDesc','REACT_ITEM_TYPE':@RM:RIType)
		
		IF INDEX(Desc,'2000',1) THEN
		
			CalcDesc = 'Kit 2000, ':RITypeDesc
			
			IF Style NE '' 		THEN CalcDesc := ' - ':Style
			IF Pressure NE ''	THEN CalcDesc := ' - ':Pressure
			
		END ELSE
		
			CalcDesc = RITypeDesc
			
			IF Style NE '' 		THEN CalcDesc := ' - ':Style
			IF Pressure NE ''	THEN CalcDesc := ' - ':Pressure
		END

		
	CASE 1
	

		* Graphite types
		
		Desc 		= ReactItemRec<REACT_ITEM_DESC$>
		RIType		= ReactItemRec<REACT_ITEM_RI_TYPE$>
		RITypeDesc	= obj_Popup('CodeDesc','REACT_ITEM_TYPE':@RM:RIType)
		SuscSize	= ReactItemRec<REACT_ITEM_SUSC_SIZE$>
		PktQty		= ReactItemRec<REACT_ITEM_PKT_QTY$>
		PktSize		= ReactItemRec<REACT_ITEM_PKT_SIZE$>

		IF INDEX(Desc,'2000',1) THEN
			CalcDesc = 'Kit 2000, '
		END ELSE
			CalcDesc = ''
		END
		
		IF PktQty = '' THEN PktQty = 1
		
		BEGIN CASE
			CASE PktQty = 1	; PktLabel = 'pkt'
			CASE PktQty > 1 ; PktLabel = 'pkts'
			CASE 1			; PktLabel = ''
		END CASE
		
		IF RIType[1,1] = 'R' THEN
			RingDesc = RITypeDesc:', ':PktSize:'in'
		END ELSE
			RingDesc = ''
		END
		
		BEGIN CASE
			CASE RingDesc NE '' AND SuscSize EQ '' AND PktSize NE ''	; CalcDesc := RingDesc
			CASE RingDesc NE '' AND SuscSize NE ''						; CalcDesc := RingDesc:' for ':SuscSize:'in Susceptor with ':PktQty:' ':PktLabel
			*CASE RingDesc EQ '' AND SuscSize NE ''						; CalcDesc := RITypeDesc:', ':SuscSize:'in with ':PktSize:'in':PktQty:' ':PktLabel			;* Replaced PktQty with PktSize -dkk 9/11/14
			CASE RingDesc EQ '' AND SuscSize NE ''						; CalcDesc := RITypeDesc:' ':SuscSize:'in, with ':PktQty: ' ':PktLabel:' @ ':PktSize:'in'			;* Replaced PktQty with PktSize -dkk 9/11/14
			CASE 1
			
		END CASE
		

		

END CASE

Result = CalcDesc

RETURN



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

RINo	= Parms[1,@RM]
RIRec	= Parms[COL2()+1,@RM]

IF RINo = '' THEN
	RETURN
END


IF RIRec = '' THEN
	RIRec = XLATE('REACT_ITEM',RINo,'','X')
	IF RIRec = '' THEN
		RETURN
	END
END

EnterDTM		= OCONV(RIRec<REACT_ITEM_ENTER_DTM$>,'DT4/^HS')
Desc			= RIRec<REACT_ITEM_DESC$>
MfrCd			= RIRec<REACT_ITEM_MFR_CD$>
MfrName			= XLATE('REACT_ITEM',RINo,'MFR_NAME','X')
MfrPartNo		= RIRec<REACT_ITEM_MFR_PART_NO$>
MfrPartNoRev	= RIRec<REACT_ITEM_MFR_PART_NO_REV$>
SerialNo		= RIRec<REACT_ITEM_SERIAL_NO$>
CurrStatus		= OCONV(XLATE('REACT_ITEM',RINo,'CURR_STATUS','X'),'[CONV_ITEM_CURR_STATUS]')
RITypeDesc		= XLATE('REACT_ITEM',RINo,'RI_TYPE_DESC','X')
SuscSize		= RIRec<REACT_ITEM_SUSC_SIZE$>
SuscSizeDesc	= XLATE('REACT_ITEM',RINo,'SUSC_SIZE_DESC','X')
PktSize			= RIRec<REACT_ITEM_PKT_SIZE$>
PktSizeDesc		= XLATE('REACT_ITEM',RINo,'PKT_SIZE_DESC','X')
PktQty			= RIRec<REACT_ITEM_PKT_QTY$>
PPlusRDSNo		= RIRec<REACT_ITEM_PPLUS_RDS_NO$>

* Build calculated description from field data

CalcDesc = obj_React_Item('CalcDesc',RINo:@RM:'')

IF PPLusRDSNo NE '' THEN
	CalcDesc := ' ( P++ )'
END


Parms = '':@RM:RINo:@RM:''
HistKeys = obj_React_Item_Hist('GetHistory',Parms)  ;* 3 parameters RINo is the middle one
HistKey = HistKeys<1,1>								;* This is the most recent 

LastInstallRec = XLATE('REACT_ITEM_HIST',HistKeys<1,1>,'','X')

ReactNo 	= HistKey[1,'*']
InstallDTM	= OCONV(FIELD(HistKey,'*',3),'DT4/^S')
RemoveDTM	= OCONV(LastInstallRec<REACT_ITEM_HIST_REM_DTM$>,'DT4/^S')

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 = '\\mesirwfp001\MESZBRPRT002'	;* 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



Str = '^XA'
Str := '^LH0,0'
Str := '^PR2'		;* Print speed 2 inches per second
Str := '^LL406'		;* Label length = 203.2dpi x 2in
Str := '^PW812'		;* Print width = 203.2dpi x 4in		;* This was 900 jch 12/30/2013
Str := '^MD15'		;* Media darkness
Str := '^MMT'		;* Media mode t=tear off mode
*Str := '^PQ2'		;* Print 2 labels for each pass through here

Str := '^FS'		;* end command

****** First Line

Str := '^FO30,25^A0,,36^FD':obj_Install('Get_Prop','Company'):'^FS'

Str := '^FO310,25^AC,18^FDRI No:^FS':CRLF$					;* Label 
Str := '^FO390,25^A045,36^FD':RINo:'^FS':CRLF$				;* Data

Str := '^FO560,25^AC,18^FDStatus:^FS':CRLF$					;* Label 
Str := '^FO650,25^A045,36^FD':CurrStatus:'^FS':CRLF$		;* Data


****** Second Line

Str:= '^FO30,70^AC,18^FDDesc:^FS':CRLF$
Str:= '^FO95,70^A050,30^FD':CalcDesc:'^FS':CRLF$

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


****** Third Line

Str:= '^FO30,115^AC,18^FDMfr:^FS'	;* Label
MfrData = MfrCd:' - ':MfrName
Str:= '^FO90,115^A0,,25^FD':MfrData:'^FS':CRLF$	;* Data


****** Fourth Line

Str:= '^FO30,160^AC,18^FDPN:^FS':CRLF$					;* Label
Str:= '^FO70,160^A045,25^FD':MfrPartNo:'^FS':CRLF$		;* Data

Str:= '^FO300,160^AC,18^FDRev:^FS':CRLF$					;* Label
Str:= '^FO350,160^A045,25^FD':MfrPartNoRev:'^FS':CRLF$		;* Data

Str:= '^FO500,160^AC,18^FDSN:^FS':CRLF$					;* Label
Str:= '^FO540,160^A045,25^FD':SerialNo:'^FS':CRLF$		;* Data



****** Separator bar

*Str:= '^FO15,128^GB795,1^FS'


****** Fifth Line

Str := '^FO30,205^AC,18^FDEntered:^FS':CRLF$
Str := '^FO150,205^A0,20^FD':EnterDTM:'^FS':CRLF$


****** Sixth Line

Str := '^FO30,250^AC,18^FDInstalled:^FS':CRLF$
Str := '^FO150,250^A0,20^FD':InstallDTM:'^FS':CRLF$


Str := '^FO500,250^AC,18^FDReact No:^FS':CRLF$
Str := '^FO610,250^A0,20^FD':ReactNo:'^FS':CRLF$

****** Seventh Line

Str := '^FO30,295^AC,18^FDRemoved:^FS':CRLF$
Str := '^FO150,295^A0,20^FD':RemoveDTM:'^FS':CRLF$

*Str := '^FO410,295^AC,18^FDReact Type:^FS':CRLF$
*Str := '^FO560,295^A0,20^FD':PrintReactType:'^FS':CRLF$



* * * * * *
Jump:
* * * * * * 

Str:= '^XZ'

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

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

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

RETURN




