COMPILE FUNCTION Comm_Dialog_Unload_Epi_Pro(Method, Parm1, Parm2)
#pragma precomp SRP_PreCompiler

/*
	Commuter module for Dialog_Unload_Epi_Pro window.
	
	05/01/2006 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Set_Status, ErrMsg, obj_RDS2, Send_Event, RDS_React_Run, Post_Event
DECLARE SUBROUTINE obj_Appwindow, Start_Window, Msg, End_Dialog, Send_Message, obj_WM_Out, obj_WM_Wfrs, obj_React_Status
DECLARE SUBROUTINE Database_Services, obj_Tables, Send_Info
DECLARE FUNCTION   Get_Property, Get_Status, Dialog_Box, Popup, obj_WM_Out, Send_Message, obj_NCR, ETMethod, obj_WM_Wfrs
DECLARE FUNCTION   Set_Property, SRP_Array, Database_Services, RDS_Services, obj_Tables

EQU CRLF$	TO \0D0A\

$INSERT POPUP_EQUATES
$INSERT LOGICAL
$INSERT MSG_EQUATES
$INSERT RDS_EQU
$INSERT RDS_TEST_EQUATES
$INSERT REACTOR_EQUATES
$INSERT RDS_EPILOAD
$INSERT NCR_EQU
$INSERT EPI_SUSCEPTOR_EQUATES
$INSERT PROD_SPEC_EQUATES
$INSERT PRS_STAGE_EQUATES
$INSERT EPI_PART_EQUATES
$INSERT QUOTE_SPEC_EQU
$INSERT WO_LOG_EQUATES
$INSERT WM_OUT_EQUATES
$INSERT APPCOLORS

EQU COL$WM_OUT_CASS		TO 1
EQU COL$WM_OUT_SLOT		TO 2

EQU COL$POCKET		TO 1
EQU COL$USAGE		TO 2
EQU COL$ZONE		TO 3
EQU COL$IN_CASS		TO 4
EQU COL$IN_SLOT		TO 5
EQU COL$WAFER_TYPE	TO 6
EQU COL$OUT_CASS	TO 7
EQU COL$OUT_SLOT	TO 8
EQU COL$OUT_NCR		TO 9

EQU COL$NCR_NO		TO 1
EQU COL$NCR_POCKET	TO 2

ErrTitle = 'Error in Comm_Dialog_Load_Epi_Pro'
ErrorMsg = ''

Result = ''

BEGIN CASE
	
	CASE Method = 'Create'				; GOSUB Create
	CASE Method = 'Close'				; GOSUB Close
	CASE Method = 'Cancel'				; GOSUB Cancel
	CASE Method = 'Refresh'				; GOSUB Refresh
	CASE Method = 'ReloadProduct'		; GOSUB ReloadProduct
	CASE Method = 'UnloadProduct'		; GOSUB UnloadProduct
	CASE Method = 'ReactIR'				; GOSUB ReactIR
	CASE Method = 'ReactDR'				; GOSUB ReactDR
	CASE Method = 'SlotOverview'		; GOSUB SlotOverview
	CASE Otherwise$
		ErrMsg(ErrTitle:@SVM:'Unknown method ':QUOTE(Method):' passed to routine.')
		
END CASE


RETURN Result


* * * * * * *
Create:
* * * * * * *
	
	obj_AppWindow('Create')
	
	* get the current style
	
	EQU MULTILINE_STYLE$	TO 512 			;* MultiLine Select
	EQU DROPDOWN_STYLE$		TO 131072
	
	Style = Get_Property(@WINDOW:'.REACTOR_TABLE', 'STYLE')									
	
	
	IF Style [1,2] _EQC "0x" THEN
		CONVERT @LOWER.CASE TO @UPPER.CASE IN STYLE
		Style = ICONV(Style [3,99], "MX")
	END
	
	Style = BitOr(Style, MULTILINE_STYLE$)
	Set_Property(@WINDOW:'.REACTOR_TABLE', "STYLE", Style)
	
	RDSNo		= FIELD(Parm1,@FM,1)
	CurrentLoad = FIELD(Parm1,@FM,2,99)
	
	IF RDSNo = '' THEN 
		ErrMsg('Null RDS No passed to Dialog Box...')
		End_Dialog(@WINDOW,'')
	END
	
	Set_Status(0)
	otParmsRDS = 'RDS':@RM:RDSNo
	RDSRec = obj_Tables('ReadRec',otParmsRDS)
	
	errCode = ''
	IF Get_Status(errCode) THEN
		ErrMsg(errCode)
		RETURN
	END
	
	Set_Property(@WINDOW,'@LOCKED_RDS',otParmsRDS)
	
	ReactorNo	= RDSRec<RDS_REACTOR$>
	WONo		= RDSRec<RDS_WO$>
	WOStepKey	= RDSRec<RDS_WO_STEP_KEY$>
	WOStep	 	= FIELD(WOStepKey,'*',2)
	
	otParms = 'WO_LOG':@RM:WONo:'*Unload'													;* Added 7/8/2009 JCH * * * * * * *
	obj_Tables('LockRec',otParms)															;* Places lock on fictional record
	
	IF Get_Status(errCode) THEN
		ErrorMsg = 'Another workstation is currently Unloading a Reactor Run for this Work Order.'
		ErrMsg(ErrorMsg)
		
		obj_Tables('UnlockRec',otParmsRDS)
		
		End_Dialog(@WINDOW,'')
		
		RETURN
	END
	
	Set_Property(@WINDOW,'@LOCKED',otParms)
	
	PSNo			= XLATE('WO_STEP',WOStepKey,1,'X')
	PSType			= XLATE('PROD_SPEC',PSNo,'SPEC_TYPE','X')				;* New reference 8/22/2012 JCH
	EpiPN			= XLATE('WO_LOG',WONo,WO_LOG_EPI_PART_NO$,'X')
	SubPostClean	= XLATE('PRS_STAGE',PSNo:'*POST',PRS_STAGE_CLEAN_TOOL$,'X')		;* SubstrateSpec<1,QSSubPostClean$>
	WaferSize 		= XLATE('EPI_PART',EpiPN,EPI_PART_SUB_WAFER_SIZE$,'X')			;* SubstrateSpec<1,QSSubWaferSize$>
	
	BEGIN CASE
		CASE WaferSize = '125 mm 5 in' ; EpiSusceptorKey = '5'
		CASE WaferSize = '150 mm 6 in' ; EpiSusceptorKey = '6'
		CASE WaferSize = '200 mm 8 in' ; EpiSusceptorKey = '8'
		CASE 1
			ErrMsg('Unknown Wafer Size ':QUOTE(WaferSize):' in PSN ':PSNo)
			End_Dialog(@WINDOW,'')
			
	END CASE
	
	EpiSusceptorRec = XLATE('EPI_SUSCEPTOR',EpiSusceptorKey,'','X')
	
	Pockets = EpiSusceptorRec<EPI_SUSCEPTOR_POCKET_NO$>
	Zones	= EpiSusceptorRec<EPI_SUSCEPTOR_POCKET_ZONE$>	
	PTypes	= EpiSusceptorRec<EPI_SUSCEPTOR_POCKET_TYPE$>
	
	Ctrls = @WINDOW:'.RDS_NO':@RM:@WINDOW:'.WO_NO':@RM:@WINDOW:'.WO_STEP':@RM:@WINDOW:'.REACTOR_NO'
	Props = 'DEFPROP':@RM: 'DEFPROP':@RM: 'DEFPROP':@RM: 'DEFPROP'
	Vals  = RDSNo:@RM:WONo:@RM:WOStep:@RM:ReactorNo
	
	Set_Property(Ctrls,Props,Vals)
	
	ProdLoadCnt		= 0
	ProdUnloadCnt	= 0
	
	LoadList = ''
	RCtrl    = @WINDOW:'.REACTOR_TABLE'
	IF CurrentLoad<1,1> = '' THEN
		
		PocketCnt = COUNT(Pockets,@VM) + (Pockets NE '')
		FOR I = 1 TO PocketCnt
			Set_Property(RCtrl,'CELLPOS',Pockets<1,I>,COL$POCKET:@FM:I)
			Set_Property(RCtrl,'CELLPOS',PTypes<1,I>,COL$USAGE:@FM:I)
			Set_Property(RCtrl,'CELLPOS',Zones<1,I>,COL$ZONE:@FM:I)
		NEXT I
		
		Set_Property(@WINDOW,'@LAST_POCKET',I-1)
		
	END ELSE
		
		* Use load data previously saved on the RDS
		
		FOR I = 1 TO COUNT(CurrentLoad<1>,@VM) + (CurrentLoad<1> NE '')
			
			Usage	= CurrentLoad<COL$USAGE,I>
			WfrType	= CurrentLoad<COL$WAFER_TYPE,I>
			OutCass	= CurrentLoad<COL$OUT_CASS,I>
			OutSlot	= CurrentLoad<COL$OUT_SLOT,I>
			
			IF WfrType = 'PROD' AND Usage = '' AND OutCass = '' THEN
				ProdLoadCnt += 1											;* Product wafers to be unloaded
			END
			
			IF OutCass NE '' THEN
				ProdUnloadCnt += 1
			END
			
			LoadList<I, COL$POCKET>     = CurrentLoad<COL$POCKET, I>
			LoadList<I, COL$USAGE>      = Usage
			LoadList<I, COL$ZONE>       = CurrentLoad<COL$ZONE, I>
			LoadList<I, COL$IN_CASS>    = CurrentLoad<COL$IN_CASS, I>
			LoadList<I, COL$IN_SLOT>    = CurrentLoad<COL$IN_SLOT, I>
			LoadList<I, COL$WAFER_TYPE> = WfrType
			LoadList<I, COL$OUT_CASS>   = OutCass
			LoadList<I, COL$OUT_SLOT>   = CurrentLoad<COL$OUT_SLOT, I>
			LoadList<I, COL$OUT_NCR>    = CurrentLoad<COL$OUT_NCR, I>
			
		NEXT I
		
		// Pad empty lines
		For I = I to 25
			LoadList<I, COL$OUT_NCR> = ''
		Next I
		
		Set_Property(RCtrl, 'LIST', LoadList)
	END
	
	
	BEGIN CASE
		CASE ProdLoadCnt > 0 AND ProdUnloadCnt = 0
			
			BriefTxt  = '{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}'
			BriefTxt := '{\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\ri200\b\f0\fs20\par Unload Product from EpiPro Reactor\par'
			BriefTxt := '\b0\par'
			BriefTxt := ' 1.) Verify Outbound Cassette and Slots\par'
			BriefTxt := ' 2.) Unload Product into Outbound Cassette\par}'
			
			Title = 'Unload Product from EpiPro Reactor'
			
			Set_Property(@WINDOW:'.UNLOAD_PRODUCT','VISIBLE',1)
			Set_Property(@WINDOW:'.RELOAD_PRODUCT','VISIBLE',0)
			
		CASE ProdLoadCnt = 0 AND ProdUnloadCnt > 0
			
			BriefTxt  = '{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}'
			BriefTxt := '{\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\ri200\b\f0\fs20\par Return Product to EpiPro Reactor\par'
			BriefTxt := '\b0\par'
			BriefTxt := ' 1.)  Return Product to Reactor\par'
			BriefTxt := '\par}'
			
			Title = 'Return Product to EpiPro Reactor'
			
			Set_Property(@WINDOW:'.UNLOAD_PRODUCT','VISIBLE',0)
			Set_Property(@WINDOW:'.RELOAD_PRODUCT','VISIBLE',1)
			
			
		CASE 1
			
			ErrMsg('No wafers loaded in Reactor.')		;* Not yet loaded
			
			
	END CASE
	
	Set_Property(@WINDOW:'.BRIEF_EDITBOX','RTFTEXT',BriefTxt)
	
	
	Set_Property(@WINDOW:'.WM_OUT_TABLE','LIST',STR(@VM:@FM,25))			;* Put empty lines in WM_OUT_TABLE
	
	IF ProdLoadCnt > 0 THEN
		
		AllOpenSlotIDs = obj_WM_Out('NextOpenSlots',WONo:@RM:WoStep)		;* Get a list of all open WMO slots on this work order
		
		OpenSlotIDs = FIELD(AllOpenSlotIDs,@FM,1,ProdLoadCnt)				;* Take the number needed to unload the reactor load
		
		IF OpenSlotIDs = '' THEN
			
			ErrMsg('No open WM_OUT slots available to unload into.')
			
			obj_Tables('UnlockRec',Get_Property(@WINDOW,'@LOCKED'))
			obj_Tables('UnlockRec',Get_Property(@WINDOW,'@LOCKED_RDS'))
			
			GOTO Cancel
		END
		
		Set_Property(@WINDOW:'.WM_OUT_TABLE','LIST',STR(@VM:@FM,25))
		
		WMOWaferKeys = ''
		
		FOR M = 1 TO ProdLoadCnt
			
			OpenSlotID = OpenSlotIDs<M>
			OpenCass = OpenSlotID<1,1>
			OpenSlot = OpenSlotID<1,2>
			Set_Property(@WINDOW:'.WM_OUT_TABLE','CELLPOS',OpenCass,COL$WM_OUT_CASS:@FM:M)		;* Load Available WMO slots into WM_OUT array
			Set_Property(@WINDOW:'.WM_OUT_TABLE','CELLPOS',OpenSlot,COL$WM_OUT_SLOT:@FM:M)
			
			WMOWaferKey = WONo:'*':WOStep:'*':OpenCass:'*':OpenSlot
			WMOWaferKeys<1,-1> = WMOWaferKey
			
		NEXT M
		
		FOR M = ProdLoadCnt + 1 TO 25
			Set_Property(@WINDOW:'.WM_OUT_TABLE','CELLPOS','',COL$WM_OUT_CASS:@FM:M)			;* Put blank lines from last Slot to bottom of display
			Set_Property(@WINDOW:'.WM_OUT_TABLE','CELLPOS','',COL$WM_OUT_SLOT:@FM:M)
		NEXT M
		
		
		Set_Status(0)
		LockedWMOKeys = obj_WM_Wfrs('LockSet','WMO_WFRS':@RM:WMOWaferKeys)		;* This locks the cass/slots available to unload into
		
		IF Get_Status(errCode) THEN
			ErrMsg(errCode)
			
			obj_Tables('UnlockRec',Get_Property(@WINDOW,'@LOCKED'))
			obj_Tables('UnlockRec',Get_Property(@WINDOW,'@LOCKED_RDS'))
			
			GOTO Cancel
			
		END ELSE
			Set_Property(@WINDOW,'@LOCKED_WFRS',LockedWMOKeys)
		END
		
	END
	
	RecordLocked = False$
	OutboundMat  = Get_Property(@Window:'.WM_OUT_TABLE', 'ARRAY')
	If OutboundMat NE '' then
		CassNos = OutboundMat<1>
		CassNos = SRP_Array('Clean', CassNos, 'TrimAndMakeUnique', @VM)
		If CassNos NE '' then
			For each CassNo in CassNos using @VM setting vPos
				WMOutKey     = WONo:'*1*':CassNo
				RecordLocked = Database_Services('IsKeyIDLocked', 'WM_OUT', WMOutKey)
				If RecordLocked then
					LockOwner = Xlate('WM_OUT', WMOutKey, 'LOCKED_BY', 'X')
					If LockOwner NE '' then
						DisplayName = Oconv(LockOwner,'[XLATE_CONV,LSL_USERS*FIRST_LAST]')
					end else
						DisplayName = 'an unknown user'
					end
					MsgParms    = ''
					MsgParms<1> = 'Record Locked'
					MsgParms<2> = 'The WM_OUT record for this RDS is locked by ':DisplayName:'. Only one user session at a time can edit an RDS.'
					Msg(@Window, '', 'OK', '', MsgParms)
					// Disable Unload button
					Set_Property(@Window:'.UNLOAD_PRODUCT', 'ENABLED', -1)
					Set_Property(@Window:'.RELOAD_PRODUCT', 'ENABLED', -1)
					Set_Property(@Window:'.SLOT_STATUS', 'ENABLED', -1)
					// Clear JCH semaphore locks and close the form
					GOSUB ClearLocks											
					End_Dialog(@WINDOW,'')
				end
			Until RecordLocked EQ True$
			Next CassNo
		end
	end
	
RETURN


* * * * * * *
Close:
* * * * * * *
	
	
	
* * * * * * *
Cancel:
* * * * * * *
	
	RDSNo		= Get_Property(@WINDOW:'.RDS_NO','DEFPROP')
	
	GOSUB ClearLocks											;* Added 3/2/2010 JCH
	
	End_Dialog(@WINDOW,'')
	
	Set_Property('RDS_UNLOAD.RDS_NO','DEFPROP',RDSNo)
	Post_Event('RDS_UNLOAD','READ')
	
RETURN


* * * * * * *
Refresh:
* * * * * * *
	
	RCtrl = @WINDOW:'.REACTOR_TABLE'
	ReactorList = Get_Property(RCtrl,'LIST')
	
	LastPocket  = Get_Property(@WINDOW,'@LAST_POCKET')
	OpenTestCnt = 0
	OpenProdCnt = 0
	LineColor   = ''
	
	FOR I = 1 TO COUNT(ReactorList,@FM) + (ReactorList NE '')
		
		IF ReactorList<I,COL$POCKET> NE '' THEN
			IF ReactorList<I,COL$USAGE> = 'PROD' THEN
				Set_Property(RCtrl,'CELLPOS','',COL$USAGE:@FM:I)
			END
			
			BEGIN CASE
				CASE ReactorList<I,COL$OUT_NCR> NE ''
					Send_Message(RCtrl,'COLOR_BY_POS',0,I,RED$)
					
				CASE ReactorList<I,COL$USAGE> = 'TEST'
					Send_Message(RCtrl,'COLOR_BY_POS',0,I,YELLOW$)
					
				CASE ReactorList<I,COL$USAGE> = 'DUMMY'
					Send_Message(RCtrl,'COLOR_BY_POS',0,I,WHITE$)
					
				CASE ReactorList<I,COL$USAGE> = 'PROD' OR ReactorList<I,COL$USAGE> = '' 
					Zone = ReactorList<I,COL$ZONE> 
					IF Zone = 1 THEN LineColor = RCV_BLUE$
					IF Zone = 2 THEN LineColor = PRE_BLUE$
					IF Zone = 3 THEN LineColor = INP_BLUE$
					IF Zone = 4 THEN LineColor = POS_BLUE$
					Send_Message(RCtrl,'COLOR_BY_POS',0,I,LineColor)
					
			END CASE
		END
		SelectedRows = Get_Property(RCtrl,'SELPOS')
		Set_Property(RCtrl,'SELPOS',SelectedRows)		;* This is a toggle - turns OFF any turned ON ************************
	NEXT I
	
RETURN


* * * * * * *
ReloadProduct:
* * * * * * *
	
	RDSNo		= Get_Property(@WINDOW:'.RDS_NO','DEFPROP')
	WONo		= Get_Property(@WINDOW:'.WO_NO','DEFPROP')
	WOStep		= Get_Property(@WINDOW:'.WO_STEP','DEFPROP')
	ReactorList	= Get_Property(@WINDOW:'.REACTOR_TABLE','LIST')			;* Updated Reactor load data
	
	WafersPulled = ''
	NCRPresent = ''
	
	FOR RP = 1 TO COUNT(ReactorList,@FM) + (ReactorList NE '')
		IF ReactorList<RP,COL$OUT_CASS> NE '' AND ReactorList<RP,COL$WAFER_TYPE> = 'PROD' AND ReactorList<RP,COL$USAGE> = '' THEN
			
			
			CassNo = ReactorList<RP,COL$OUT_CASS>
			SlotNo = ReactorList<RP,COL$OUT_SLOT>
			Pocket = ReactorList<RP,COL$POCKET>
			
			WMOutRec = XLATE('WM_OUT',WONo:'*':WOStep:'*':CassNo,'','X')
			
			LOCATE SlotNo IN WMOutRec<WM_OUT_SLOT_NO$> USING @VM SETTING Pos THEN
				IF WMOutRec<WM_OUT_RDS$,Pos> = '' THEN WafersPulled = 1
				IF WMOutRec<WM_OUT_SLOT_NCR$,Pos> NE '' THEN NCRPresent = 1
			END
			IF WafersPulled THEN ErrorMsg = 'Wafers pulled from WM_OUT ':SlotNo:' cannot reload reactor.'
			IF NCRPresent THEN ErrorMsg = 'NCR issued for Slot No ':SlotNo:' in WM_OUT.  Cannot reload reactor.'
			IF ErrorMsg NE '' THEN
				ErrMsg(ErrorMsg)
				GOTO Close
			END
			
		END
	NEXT RP
	
	OrgColor = Set_Property('DIALOG_UNLOAD_EPI_PRO.STATUSLINE_FIX','BACKCOLOR',YELLOW$)	;* //////// Messaging
	
	
	GOSUB ClearLocks											;* Added 3/2/2010 JCH
	
	
	Set_Status(0)
	
	obj_RDS2('ReloadEpi',RDSNo)
	
	Send_Info(STR(' ',60))																;** - Messaging - **
	Dummy = Set_Property('DIALOG_UNLOAD_EPI_PRO.STATUSLINE_FIX','BACKCOLOR',OrgColor)	;** - Messaging - **
	
	IF Get_Status(ErrCode) THEN
		ErrMsg(ErrCode)
	END
	
	GOTO Close
	
RETURN


* * * * * * *
UnloadProduct:
* * * * * * *
	
	ReactCtrl = @WINDOW:'.REACTOR_TABLE'
	WMOutCtrl = @WINDOW:'.WM_OUT_TABLE'
	
	* Get PROD wafers in the reactor
	
	WONo	= Get_Property(@WINDOW:'.WO_NO','DEFPROP')
	WOStep	= Get_Property(@WINDOW:'.WO_STEP','DEFPROP')
	RDSNo	= Get_Property(@WINDOW:'.RDS_NO','DEFPROP')
	
	PostInstAckReq = Xlate('RDS', RDSNo, 'POST_INST_ACK_REQ', 'X')
	If PostInstAckReq EQ True$ then
		Response = RDS_Services('RDSVerifyInst', RDSNo, 'POST')
		If Response EQ False$ then return
	end
	
	ReactorList		= Get_Property(ReactCtrl,'LIST')			;* Updated Reactor load data
	AvailSlotKeys	= Get_Property(@WINDOW,'@LOCKED_WFRS')		;* Available & locked outbound slots
	
	OrgColor = Set_Property('DIALOG_UNLOAD_EPI_PRO.STATUSLINE_FIX','BACKCOLOR',YELLOW$)	;* //////// Messaging
	
	orParms = RDSNo:@RM:ReactorList:@RM:AvailSlotKeys
	
	GOSUB ClearLocks											;* Added 3/2/2010 JCH
	
	Abort   = False$
	// Lock outbound cassette records BEFORE modifying any records!
	CassNos = AvailSlotKeys
	Swap @VM with @FM in CassNos
	Swap '*' with @VM in CassNos
	CassNos = SRP_Array('Rotate', CassNos, @FM, @VM)
	CassNos = CassNos<3>
	CassNos = SRP_Array('Clean', CassNos, 'TrimAndMakeUnique', @VM)
	
	For each CassNo in CassNos using @VM
		WMOKey   = WONo:'*':WOStep:'*':CassNo
		HaveLock = Database_Services('GetKeyIDLock', 'WM_OUT', WMOKey)
		If HaveLock EQ False$ then
			Abort = True$
			ErrMsg('Error unloading RDS. Outbound cassette ':WMOKey:' is locked!')
		end
	Until Abort
	Next CassNo
	
	If Abort EQ False$ then
		Set_Status(0)
		obj_RDS2('UnloadEpi',orParms)
		// Successfully unloaded RDS. Unlock necessary WM_OUT records.
		For each CassNo in CassNos using @VM
			WMOKey   = WONo:'*':WOStep:'*':CassNo
			HaveLock = Database_Services('IsKeyIDLocked', 'WM_OUT', WMOKey)
			If HaveLock then
				Database_Services('ReleaseKeyIDLock', 'WM_OUT', WMOKey)
			end
		Next CassNo
		
		Send_Info(STR(' ',60))																;** - Messaging - **
		Dummy = Set_Property('DIALOG_UNLOAD_EPI_PRO.STATUSLINE_FIX','BACKCOLOR',OrgColor)	;** - Messaging - **
		
		IF Get_Status(ErrCode) THEN
			ErrMsg(ErrCode)
		END
		
		GOTO Close
	end else
		// Failed to lock necessary WM_OUT records. Unlock those set by this user.
		For each CassNo in CassNos using @VM
			WMOKey   = WONo:'*':WOStep:'*':CassNo
			HaveLock = Database_Services('IsKeyIDSelfLocked', 'WM_OUT', WMOKey)
			If HaveLock then
				Database_Services('ReleaseKeyIDLock', 'WM_OUT', WMOKey)
			end
		Next CassNo
	end
	
RETURN


* * * * * * *
ReactIR:
* * * * * * *
	
	RowIndex = Parm1
	
	IF RowIndex = '' THEN RETURN
	
	CtrlID = @WINDOW:'.REACTOR_TABLE'
	
	Dummy = Send_Message(CtrlID,'DELETE',RowIndex)
	
	GOSUB Refresh
	
RETURN


* * * * * * *
ReactDR:
* * * * * * *
	
	RowIndex = Parm1
	RowData = Parm2
	
	IF RowIndex = '' THEN RETURN
	
	CtrlID = @WINDOW:'.REACTOR_TABLE'
	
	Dummy = Send_Message(CtrlID, "INSERT", RowIndex, RowData)
	
	GOSUB Refresh
	
RETURN


* * * * * * *
ClearLocks:
* * * * * * *
	
	WMOLocks	= Get_Property(@WINDOW,'@LOCKED_WFRS')				;* Lock on Wafer Slots
	RDSLocks	= Get_Property(@WINDOW,'@LOCKED_RDS')
	WinLock		= Get_Property(@WINDOW,'@LOCKED')
	
	Set_Status(0)
	IF WMOLocks NE '' THEN obj_WM_Wfrs('UnlockSet','WMO_WFRS':@RM:WMOLocks)		;* Remove locks on the wafer slots
	IF Get_Status(errCode) THEN ErrMsg(errCode)
	
	Set_Status(0)
	IF RDSLocks NE '' THEN obj_Tables('UnlockRec',RDSLocks)						;* Unlocks the RDS Record
	IF Get_Status(errCode) THEN ErrMsg(errCode)
	
	Set_Status(0)
	IF WinLock NE ''  THEN obj_Tables('UnlockRec',WinLock)						;* Removes WO unload window lock
	IF Get_Status(errCode) THEN ErrMsg(errCode)
	
RETURN


* * * * * * *
SlotOverview:
* * * * * * *
	
	WONo	= Get_Property(@WINDOW:'.WO_NO','DEFPROP')
	WOStep	= Get_Property(@WINDOW:'.WO_STEP','DEFPROP')
	
	DisplayList = obj_WM_Out('SlotStatus',WONo:@RM:WOStep)
	
	CONVERT @VM TO @SVM IN DisplayList
	CONVERT @FM TO @VM IN DisplayList
	
	TypeOver = ''
	TypeOver<PDISPLAY$> = DisplayList
	
	void = Popup(@WINDOW,TypeOver,'WM_OUT_SLOT_STATUS')
	
RETURN



