COMPILE FUNCTION REACT_RUN_DISP(EntID,Event,Parm1,Parm2,Parm3,Parm4,Parm5)
#pragma precomp SRP_PreCompiler

/*
	Commuter module for REACT_RUN_DISP window.- Cloned from DIALOG_SPLIT_WAFERS
	
	06/229/2016 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Set_Status, ErrMsg, obj_RDS2, Send_Event, RDS_React_Run, Send_Info, obj_React_Run, obj_WO_Wfr, Post_Event
DECLARE SUBROUTINE obj_Post_Log, Post_Event, Forward_Event
DECLARE SUBROUTINE obj_Appwindow, Start_Window, Msg, End_Dialog, Send_Message, obj_MAT_INBOUND, obj_WM_Wfrs, obj_React_Status, obj_WO_Wfr_WIP, obj_Run_Stage_Wfr
DECLARE SUBROUTINE obj_Tables
DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Popup, obj_WM_In, Send_Message, obj_NCR, obj_WM_Wfrs, Set_Property, obj_WO_Mat_Wfr, obj_WO_Wfr_WIP
DECLARE FUNCTION obj_WO_Wfr
DECLARE FUNCTION obj_Prod_Spec, NextKey, obj_Test_Wafer
DECLARE FUNCTION obj_Tables

EQU CRLF$	TO \0D0A\

$INSERT APPCOLORS
$INSERT MSG_EQUATES
$INSERT POPUP_EQUATES
$INSERT PROD_SPEC_EQUATES
$INSERT PRS_STAGE_EQUATES
$INSERT QUOTE_SPEC_EQU
$INSERT RDS_LAYER_EQUATES
$INSERT RDS_TEST_EQUATES
$INSERT REACT_RUN_EQUATES
$INSERT REACTOR_EQUATES
$INSERT RTI_STYLE_EQUATES
$INSERT RUN_STAGE_EQUATES
$INSERT RUN_STAGE_WFR_EQUATES
$INSERT TOOL_CLASS_EQUATES
$INSERT TOOL_EQUATES
$INSERT WO_LOG_EQUATES
$INSERT WO_MAT_EQUATES
$INSERT WO_STEP_EQU
$INSERT WO_VERIFY_EQU
$INSERT WO_WFR_EQUATES
$INSERT LOGICAL

EQU COL$CHAR_WFR_ID			TO 1
EQU COL$CHAR_SCRIBE			TO 2
EQU COL$CHAR_CURR_STAGE		TO 3
EQU COL$CHAR_DESTROYED		TO 4
EQU COL$CHAR_TW_NO			TO 5
EQU COL$CHAR_WFR_STATUS		TO 6
EQU COL$CHAR_RETURN_BY		TO 7
EQU COL$CHAR_RETURN_DTM		TO 8

EQU COL$CARR_SLOT_NO		TO 1
EQU COL$CARR_WFR_ID			TO 2
EQU COL$CARR_SCRIBE			TO 3
EQU COL$CARR_GRADE			TO 4
EQU COL$CARR_NCR			TO 5
EQU COL$CARR_WFR_SHIP		TO 6
EQU COL$CARR_SHIP_ID		TO 7
EQU COL$CARR_RETAIN_WFR		TO 8
EQU COL$CARR_RET_CASS_ID	TO 9
EQU COL$CARR_RET_SLOT		TO 10
EQU COL$CARR_PREV_WFR_ID	TO 11

EQU COL$NCR_NO			TO 1
EQU COL$NCR_STATUS		TO 2
EQU COL$NCR_REJ_QTY		TO 3
EQU COL$NCR_RESP		TO 4
EQU COL$NCR_STAGE		TO 5
EQU COL$NCR_LOSS_DESC	TO 6
EQU COL$NCR_LOSS_COMM	TO 7
EQU COL$NCR_FIN_SIG		TO 8
EQU COL$NCR_FIN_SIG_DTM	TO 9

EQU COL$OUT_SLOT_ID	TO 1
EQU COL$OUT_WFR_ID	TO 2
EQU COL$OUT_SCRIBE	TO 3

EQU WM_USER$		TO 1024
EQU DTM_SELROW$		TO (WM_USER$ + 59)
EQU DTM_SELALLROWS$	TO (WM_USER$ + 61)
EQU ETM_INSERTROW$	TO (WM_USER$ + 2004)
EQU ETM_DELETEROW$	TO (WM_USER$ + 2005)
EQU DTPOS_INVALID$	TO -3

/*
EQU EDITABLE$			TO 4
EQU PROTECTED$			TO 8			;* Protected  - Edittable COLSTYLE constants
EQU MULTILINE_STYLE$	TO 512 			;* MultiLine Select
EQU LOCKED$				TO 8192
EQU DROPDOWN_STYLE$		TO 131072
*/

ErrTitle = 'Error in React_Run_Disp commuter module'
ErrorMsg = ''
ErrCode  = ''

Result = ''

BEGIN CASE

	CASE EntID = @WINDOW
		BEGIN CASE
			CASE Event = 'CREATE' 			; GOSUB Create
			CASE Event = 'READ'				; GOSUB Read
			CASE Event = 'WRITE'			; GOSUB Write
			CASE Event = 'CLOSE'			; GOSUB Close			;* This needs to be a PRECLOSE event!
			
			CASE Event[1,3] = 'QBF'			; GOSUB Refresh
		END CASE
	
	CASE EntID = @WINDOW:'.LOG_TEST_WFR'		AND Event = 'CLICK'		; GOSUB LogTestWfr
	CASE EntID = @WINDOW:'.REJECT_MATERIAL'		AND Event = 'CLICK'		; GOSUB RejMat
	CASE EntID = @WINDOW:'.RETURN_CHAR'			AND Event = 'CLICK'		; GOSUB ReturnChar
	CASE EntID = @WINDOW:'.AVAILABLE_SLOTS'		AND Event = 'CLICK'		; GOSUB GetAvailableSlots
	CASE EntID = @WINDOW:'.UNLOAD_WAFERS'		AND Event = 'CLICK'		; GOSUB UnloadWafers
	
	CASE EntID = @WINDOW:'.NCR_KEYS'			AND Event = 'DBLCLK'	; GOSUB NCRKeysDC
	
	CASE EntID = @WINDOW:'.CARR_WFRS'

		BEGIN CASE
			CASE Event = 'OPTIONS'		; GOSUB CarrOptions
			CASE Event = 'DBLCLK'		; GOSUB CarrWfrsDC
			CASE Event = 'POSCHANGED'	; GOSUB CarrWfrsPC
			CASE Event = 'CLICK'		; GOSUB CarrWfrsClick
			CASE Event = 'WINMSG'		; GOSUB TrapKeys
			
		END CASE
	
	CASE EntID = @WINDOW:'.CHAR_WFRS'
	
		BEGIN CASE 
		
			CASE Event = 'DBLCLK'		; GOSUB CharWfrsDC
			
		END CASE
		
	
	CASE 1
		ErrorMsg = 'Unknown Parameters ':EntID:' - ':Event:' passed to commuter'
		ErrMsg(ErrorMsg)
		
END CASE

IF ErrorMsg NE '' THEN
	ErrMsg(ErrTitle:@SVM:ErrorMsg)
END


RETURN Result



* * * * * * *
Create:
* * * * * * *

obj_AppWindow('Create')

eventOp    = TRUE$ ; * // Turn tracking on
eventOp<4> = TRUE$ ; * // Track Synchronously
CALL send_Message( @window : ".CARR_WFRS", "QUALIFY_EVENT", ETM_DELETEROW$, eventOp )
CALL send_Message( @window : ".CARR_WFRS", "QUALIFY_EVENT", ETM_INSERTROW$, eventOp )

CarrStyles = Send_Message(@WINDOW:'.CARR_WFRS','COLSTYLE',0,'')

CarrStyles<COL$CARR_GRADE>		= BitOr(CarrStyles<COL$CARR_GRADE>,DTCS_OPTIONSBUTTON$)

CarrStyles<COL$CARR_WFR_SHIP>	= BitOr(CarrStyles<COL$CARR_WFR_SHIP>,DTCS_CHECKBOX$)
CarrStyles<COL$CARR_WFR_SHIP>	= BitOr(CarrStyles<COL$CARR_WFR_SHIP>,DTCS_CHECKBOXCENTER$)

CarrStyles<COL$CARR_RETAIN_WFR>	= BitOr(CarrStyles<COL$CARR_RETAIN_WFR>,DTCS_CHECKBOX$)
CarrStyles<COL$CARR_RETAIN_WFR>	= BitOr(CarrStyles<COL$CARR_RETAIN_WFR>,DTCS_CHECKBOXCENTER$)

void = Send_Message(@WINDOW:'.CARR_WFRS','COLSTYLE',0,CarrStyles)

GOSUB Refresh

RETURN


* * * * * * *
LogTestWfr:
* * * * * * *

RDSNo		= Get_Property(@WINDOW:'.RDS_NO','DEFPROP')
ReactNo		= Get_Property(@WINDOW:'.REACTOR','DEFPROP')
CharList	= Get_Property(@WINDOW:'.CHAR_WFRS','LIST')
CharArray	= Get_Property(@WINDOW:'.CHAR_WFRS','DEFPROP')

IF RDSNo = '' THEN RETURN

CharWfrIDs = ''

WfrCnt = 0

clCnt = COUNT(CharList,@FM) + (CharList NE '')
	
FOR I = 1 TO clCnt

	TWNo			= CharList<I,COL$CHAR_TW_NO>
	CharWfrID		= CharList<I,COL$CHAR_WFR_ID>
	CharCurrStage	= CharList<I,COL$CHAR_CURR_STAGE>
	CharWfrStatus	= CharList<I,COL$CHAR_WFR_STATUS>
		
	IF TWNo = '' AND CharWfrID NE '' THEN
	
		BEGIN CASE
			CASE CharWfrStatus = 'PART'
				Msg(@WINDOW,'','PART_CHAR','',CharWfrID)
	
			CASE CharWfrStatus = 'COMP'
				WfrCnt += 1
				CharWfrIDs<1,WfrCnt> = CharWfrID
			
			
			CASE 1
				Msg(@WINDOW,'','CHAR_WFR_NOT_DONE','',CharWfrID)
				
		END CASE
	
	END
	
NEXT I

IF WfrCnt = 0 THEN
	ErrMsg('No Characterization Wafers are ready for disposition')
	RETURN
END



TWNo = obj_Test_Wafer('Create',RDSNo:@RM:CharWfrIDs)

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

Parms  = 'TEST_WAFER':@RM
Parms := TWNo:@RM
Parms := ''							;* Optional parameters

obj_Appwindow('ViewRelated',Parms)

clCnt = COUNT(CharList,@FM) + (CharList NE '')

cwPointer = 1

CurrDTM =  OCONV(Date(),'D4/'):' ':OCONV(Time(),'MTS')

FOR I = 1 TO clCnt 
	CurrTWNo = CharArray<COL$CHAR_TW_NO,I>
	CharWfr = CharArray<COL$CHAR_WFR_ID,I>
	
	IF CharWfr NE  '' AND CurrTWNo = '' THEN
	
		CharWfrID = CharWfrIDs<1,cwPointer>
		
		CurrLocs = obj_WO_Wfr('CurrLoc',CharWfrID)
			
		WOMatLoc 	= CurrLocs<1,1>		;* Only 1 of these can be set others will be null
		ToolLoc		= CurrLocs<1,2>
		InvIDLoc	= CurrLocs<1,3>
		
		Parms  = CharWfrID:@RM						;* WfrID
		Parms := CurrDTM:@RM						;* EventDtm
		Parms := @USER4:@RM							;* EventBy
		Parms := 'TEST':@RM							;* Event
		Parms := '':@RM								;* NewSlotID
		Parms := '':@RM								;* RunLoc
		Parms := '':@RM								;* NCRNo
		Parms := TWNo:@RM							;* TWUse Key OR TWNo
		Parms := WOMatLoc:@RM						;* CurrSlotID
		Parms := '':@RM								;* NewToolID
		Parms := ToolLoc:@RM						;* CurrToolID
		Parms := '':@RM								;* NewInvLoc
		Parms := InvIDLoc:@RM						;* CurrInvLoc
		Parms := 'O':@RM							;* Inbound or Outbound Wafers
		Parms := '':@RM								;* NewCarrLoc
		Parms := ''									;* CurrCarrLoc	

		obj_WO_Wfr('AddEvent',Parms)

		CharArray<COL$CHAR_TW_NO,I> = TWNo
		
		cwPointer += 1
	END
NEXT I

Set_Property(@WINDOW:'.CHAR_WFRS','DEFPROP',CharArray)

RETURN



* * * * * * *
Read:
* * * * * * * 

OrgRecord = Get_Property(@WINDOW,'RECORD')		;* Record as read in

Set_Property(@WINDOW,'@ORG_RECORD',OrgRecord)	;* Save to dynamic property of the window

RDSNo = Get_Property(@WINDOW:'.RDS_NO','TEXT')

RunStageKey = RDSNo:'*DISP'

DispStageStatus = XLATE('RUN_STAGE',RunStageKey,'CURR_STATUS','X')

Set_Property(@WINDOW:'.STAGE_STATUS','DEFPROP',DispStageStatus)

GOTO Refresh

RETURN


* * * * * * *
Write:
* * * * * * *

* This is called from a routine on the REACT_RUN_DISP window 'WRITE' event as a PRE_EVENT *

SkipUpdate = Get_Property(@WINDOW,'@SKIP_WRITE_UPDATE')		;* Set by the Create NCR and NCRKeysDC events so the window doesn't close!

IF SkipUpdate THEN
	Forward_Event()					;* Performs the Write
	Result = 0
	Set_Property(@WINDOW,'@SKIP_WRITE_UPDATE','')
	RETURN
END

OrgRec = Get_Property(@WINDOW,'@ORG_RECORD')
Record = Get_Property(@WINDOW,'ATRECORD')

aOrg = OrgRec<99>
aRec = Record<99>

CarrSlotIDs = Record<REACT_RUN_CARR_SLOT_ID$>
csCnt = COUNT(CarrSlotIDs,@VM) + (CarrSlotIDs NE '')

FOR I = 1 TO csCnt
	WfrID	= Record<REACT_RUN_CARR_PREV_WFR_ID$,I>
	If WfrID EQ '' then WfrID = Record<REACT_RUN_CARR_WFR_ID$,I>
	RetKey	= Record<REACT_RUN_GAN_RET_KEY$,I>
	RetSlot	= Record<REACT_RUN_GAN_RET_SLOT$,I>
	
	WfrGrade	= Record<REACT_RUN_CARR_WFR_GRADE$,I>
	WfrShipFlag = Record<REACT_RUN_CARR_WFR_SHIP$,I>
	
	FieldNos	= WO_WFR_GRADE$:@VM:WO_WFR_SHIP_FLAG$
	FieldVals	= WfrGrade:@VM:WfrShipFlag
	
	IF (WfrID NE '') THEN
	
		obj_WO_Wfr('SetProp',WfrID:@RM:FieldNos:@RM:FieldVals)
		
		IF Get_Status(errCode) THEN
			ErrMsg(errCode)
		END

		***************************************
		* Move "Shipped" wafers to PACK stage *
		***************************************
		OrgShipFlag	= OrgRec<REACT_RUN_CARR_WFR_SHIP$,I>
		ShipFlag	= Record<REACT_RUN_CARR_WFR_SHIP$,I>
		
		IF OrgShipFlag = '' THEN OrgShipFlag	= 0
		IF ShipFlag = ''	THEN ShipFlag		= 0
	
		CurrInvLoc = obj_WO_Wfr('CurrLoc',WfrID)<1,4>
		
		NewInvLoc = ''
		MoveFlag = ''

		BEGIN CASE
			CASE (OrgShipFlag = 0) AND (ShipFlag = 1) AND (CurrInvLoc = 'GGR*Q_DISP')
				NewInvLoc = 'GCH*Q_PACK'
				MoveFlag  = 1
				
			CASE (OrgShipFlag = 1) AND (ShipFlag = 0) AND (CurrInvLoc = 'GCH*Q_PACK')
				NewInvLoc = 'GGR*Q_DISP'
				MoveFlag = 1
			
			CASE 1
				NULL
		END CASE
		
		IF MoveFlag THEN
			CurrDTM =  OCONV(Date(),'D4/'):' ':OCONV(Time(),'MTS')	
			Parms  = WfrID:@RM							;* WfrID
			Parms := CurrDTM:@RM						;* EventDtm
			Parms := @USER4:@RM							;* EventBy
			Parms := 'PACK':@RM							;* Event
			Parms := '':@RM								;* NewSlotID
			Parms := '':@RM								;* RunLoc
			Parms := '':@RM								;* NCRNo
			Parms := '':@RM								;* TWUse Key OR TWNo
			Parms := '':@RM								;* CurrSlotID
			Parms := '':@RM								;* NewToolID
			Parms := '':@RM								;* CurrToolID
			Parms := NewInvLoc:@RM						;* NewInvLoc
			Parms := CurrInvLoc:@RM						;* CurrInvLoc
			Parms := 'O':@RM							;* Inbound or Outbound Wafers
			Parms := '':@RM								;* NewCarrLoc
			Parms := ''									;* CurrCarrLoc	
			obj_WO_Wfr('AddEvent',Parms)
		END	;* End of Check for MoveFlag

		***************************************
		* Move "Retained" wafers to PACK stage *
		***************************************
		OrgRetainFlag = OrgRec<REACT_RUN_GAN_RET_WFR$,I>
		RetainFlag    = Record<REACT_RUN_GAN_RET_WFR$,I>
		
		IF OrgRetainFlag = '' THEN OrgRetainFlag = 0
		IF RetainFlag    = '' THEN RetainFlag    = 0

		CurrInvLoc = obj_WO_Wfr('CurrLoc',WfrID)<1,4>
		
		NewInvLoc = ''
		MoveFlag = ''
			
		BEGIN CASE
			CASE (OrgRetainFlag = 0) AND (RetainFlag = 1) AND (CurrInvLoc = 'GGR*Q_DISP')
				NewInvLoc = 'GCH*Q_PACK'
				MoveFlag  = 1
				
			CASE (OrgRetainFlag = 1) AND (RetainFlag = 0) AND (CurrInvLoc = 'GCH*Q_PACK')
				NewInvLoc = 'GGR*Q_DISP'
				MoveFlag  = 1
			
			CASE 1
				NULL
		END CASE
		
		IF MoveFlag THEN
			CurrDTM =  OCONV(Date(),'D4/'):' ':OCONV(Time(),'MTS')	
			Parms  = WfrID:@RM							;* WfrID
			Parms := CurrDTM:@RM						;* EventDtm
			Parms := @USER4:@RM							;* EventBy
			Parms := 'GRET':@RM							;* Event
			Parms := '':@RM								;* NewSlotID
			Parms := '':@RM								;* RunLoc
			Parms := '':@RM								;* NCRNo
			Parms := '':@RM								;* TWUse Key OR TWNo
			Parms := '':@RM								;* CurrSlotID
			Parms := '':@RM								;* NewToolID
			Parms := '':@RM								;* CurrToolID
			Parms := NewInvLoc:@RM						;* NewInvLoc
			Parms := CurrInvLoc:@RM						;* CurrInvLoc
			Parms := 'O':@RM							;* Inbound or Outbound Wafers
			Parms := '':@RM								;* NewCarrLoc
			Parms := ''									;* CurrCarrLoc	
			obj_WO_Wfr('AddEvent',Parms)
		END	;* End of Check for MoveFlag

		*****************************************
		* Move "Destroyed" wafers to PACK stage *
		*****************************************
		CurrInvLoc = obj_WO_Wfr('CurrLoc',WfrID)<1,4>
		
		NewInvLoc = ''
		MoveFlag  = ''
		CharWfrID = ''

		CtrlID = @WINDOW:'.CHAR_WFRS'
		CharWfrList = Get_Property(CtrlID,'LIST')
		FOR CharWfrListIndex = 1 TO COUNT(CharWfrList,@FM) + (CharWfrList NE '') AND (CharWfrID NE WfrID)
			CharWfrID   = CharWfrList<CharWfrListIndex,COL$CHAR_WFR_ID>
			CharDest	= CharWfrList<CharWfrListIndex,COL$CHAR_DESTROYED>
			StageStatus	= CharWfrList<CharWfrListIndex,COL$CHAR_WFR_STATUS>
		NEXT CharWfrListIndex

		BEGIN CASE
			CASE (CharWfrID = WfrID) AND ((CharDest = 'Yes') AND (StageStatus = 'COMP')) AND (CurrInvLoc = 'GGR*Q_DISP')
				NewInvLoc = 'GCH*Q_PACK'
				MoveFlag  = 1
				
			CASE (CharWfrID = WfrID) AND ((CharDest NE 'Yes') OR (StageStatus NE 'COMP')) AND (CurrInvLoc = 'GCH*Q_PACK')
				NewInvLoc = 'GGR*Q_DISP'
				MoveFlag  = 1
			
			CASE 1
				NULL
		END CASE
		
		IF MoveFlag THEN
			CurrDTM =  OCONV(Date(),'D4/'):' ':OCONV(Time(),'MTS')	
			Parms  = WfrID:@RM							;* WfrID
			Parms := CurrDTM:@RM						;* EventDtm
			Parms := @USER4:@RM							;* EventBy
			Parms := 'DEST':@RM							;* Event
			Parms := '':@RM								;* NewSlotID
			Parms := '':@RM								;* RunLoc
			Parms := '':@RM								;* NCRNo
			Parms := '':@RM								;* TWUse Key OR TWNo
			Parms := '':@RM								;* CurrSlotID
			Parms := '':@RM								;* NewToolID
			Parms := '':@RM								;* CurrToolID
			Parms := NewInvLoc:@RM						;* NewInvLoc
			Parms := CurrInvLoc:@RM						;* CurrInvLoc
			Parms := 'O':@RM							;* Inbound or Outbound Wafers
			Parms := '':@RM								;* NewCarrLoc
			Parms := ''									;* CurrCarrLoc	
			obj_WO_Wfr('AddEvent',Parms)
		END	;* End of Check for MoveFlag

	END	;* End of Check for no WfrID
	
NEXT I

Result = 0						;* Set Flag to stop window POSTEVENT chain 
Forward_Event()					;* Performs the Write
Post_Event(@WINDOW,'CLOSE')		;* All Done go back to calling window

RETURN 


* * * * * * *
Clear:
* * * * * * *


* * * * * * *
Close:
* * * * * * *

Parent = Get_Property('REACT_RUN_DISP','PARENT')

IF Parent = 'REACT_RUN' THEN 
	Send_Event(@WINDOW,'CLEAR')
END

obj_AppWindow('DetailReturn')

RETURN




* * * * * * *
Refresh:
* * * * * * *


CarrList = Get_Property(@WINDOW:'.CARR_WFRS','LIST')
carrCnt = COUNT(CarrList,@FM) + (CarrList NE '')

CharList = Get_Property(@WINDOW:'.CHAR_WFRS','LIST')
CharScribes = Get_Property(@WINDOW:'.CHAR_WFRS','ARRAY')<COL$CHAR_SCRIBE>
charCnt = COUNT(CharList,@FM) + (CharList NE '')

FOR I = 1 TO CarrCnt

	CharWfr = 0
	ScribeID = CarrList<I,COL$CARR_SCRIBE>
	IF (charCnt > 0) AND (ScribeID NE '') THEN
		LOCATE ScribeID IN CharScribes USING @VM SETTING Pos THEN
			CharWfr = 1
		END
	END
	
	LineColor = WHITE$
	BEGIN CASE
		CASE (CarrList<I,COL$CARR_GRADE> = 'SCR') OR (CarrList<I,COL$CARR_NCR> NE '')
			/* Bad Wafer */
			LineColor = RED$

		CASE (CharWfr = 1)
			/* Wafer located in characterization */
			LineColor = YELLOW$

		CASE (CarrList<I,COL$CARR_SHIP_ID> NE '')
			/* Wafer has been shipped */
			LineColor = GREEN$
			
		CASE (CarrList<I,COL$CARR_RET_CASS_ID> NE '')
			/* Wafer has been retained */
			LineColor = BLUE$
			
		CASE 1
			NULL
	END CASE

	stat = Send_Message(@WINDOW:'.CARR_WFRS','COLOR_BY_POS',0,I,LineColor)
	
NEXT I


/*

CharList = Get_Property(@WINDOW:'.CHAR_WFRS','LIST')
charCnt = COUNT(CharList,@FM) + (CharList NE '')

FOR I =1 TO CharCnt

	BEGIN CASE
		CASE CharList<I,COL$CHAR_RETURN_BY> NE ''	; LineColor = YELLOW$
		CASE 1										; LineColor = GREEN$
	END CASE
	
	stat = Send_Message(@WINDOW:'.CHAR_WFRS','COLOR_BY_POS',0,I,LineColor)
	
NEXT I
*/


* Turn edit table symbolic column backgrounds to green

ETSymbolics = Get_Property(@WINDOW,'@ET_SYMBOLICS')		;* Loaded during 'Create' in obj_Appwindow

ETCtrls	= ETSymbolics<1>
ETCols	= ETSymbolics<2>

FOR I = 1 TO COUNT(ETCtrls,@VM) + (ETCtrls NE '')
	ETCtrl	= ETCtrls<1,I>
	IF ETCtrl NE @WINDOW:'.SIG_PROFILE' AND ETCtrl NE @WINDOW:'.CHAR_WFRS' AND ETCtrl NE @WINDOW:'.CARR_WFRS' THEN
		ETList = Get_Property(ETCtrl,'LIST')
		FOR Line = 1 TO COUNT(ETList,@FM) + (ETList NE '')
			IF ETList<Line,1> NE '' THEN
				FOR N = 1 TO COUNT(ETCols<1,I>,@SVM) + (ETCols<1,I> NE '')
					stat = Send_Message(ETCtrl,'COLOR_BY_POS',ETCols<1,I,N>,Line,GREEN$)
				NEXT N
			END
		NEXT Line
	END	;* End of check for .SIG_PROFILE control
NEXT I


CtrlID = @WINDOW:'.CHAR_WFRS'

CharWfrList = Get_Property(CtrlID,'LIST')


FOR I = 1 TO COUNT(CharWfrList,@FM) + (CharWfrList NE '')

	CurrStage	= CharWfrList<I,COL$CHAR_CURR_STAGE>
	CharDest	= CharWfrList<I,COL$CHAR_DESTROYED>
	StageStatus	= CharWfrList<I,COL$CHAR_WFR_STATUS>
	ReturnBy	= CharWfrList<I,COL$CHAR_RETURN_BY>
		
		BEGIN CASE
			CASE StageStatus EQ 'RUN'		; LineColor = LS3_GREEN$
			CASE StageStatus EQ 'SIG' 		; LineColor = ORANGE$
			CASE StageStatus EQ 'PART'		; LineColor = GREY$
			CASE 1							; LineColor = GREEN$
		END CASE
		
		* * * * * * *  Change to display 'DEST' column to red if destroyed, rest of line to LineColor  ********** ****************************
	
	BEGIN CASE
	
		CASE CurrStage = 'COMP'		; ParmColor = GREEN$
		CASE CurrStage NE ''		; ParmColor = LineColor
		CASE 1						; ParmColor = WHITE$
		
	END CASE

	stat = Send_Message(CtrlID,'COLOR_BY_POS',0,I,ParmColor)
	
	IF CharDest = 'Yes' THEN
		stat = Send_Message(CtrlID,'COLOR_BY_POS',COL$CHAR_DESTROYED,I,RED$)
	END
	
	IF ReturnBy NE '' THEN
		stat = Send_Message(CtrlID,'COLOR_BY_POS',COL$CHAR_RETURN_BY,I,YELLOW$)
		stat = Send_Message(CtrlID,'COLOR_BY_POS',COL$CHAR_RETURN_DTM,I,YELLOW$)
	END
	
NEXT I

RETURN


* * * * * * *
GetAvailableSlots:
* * * * * * *

WONo = Get_Property(@WINDOW:'.WO_NO','DEFPROP')

CarrCtrl = @WINDOW:'.CARR_WFRS'

CarrArray	= Get_Property(CarrCtrl,'INVALUE')
ShipFlags	= CarrArray<COL$CARR_WFR_SHIP>
WfrIDs		= CarrArray<COL$CARR_WFR_ID>

cCnt = COUNT(CarrArray,@FM) + (CarrArray NE '')

ShipWfrIDs = ''
ShipCnt  = 0
FOR I = 1 to cCnt

	ShipFlag	= ShipFlags<1,I>
	WfrID		= WfrIDs<1,I>
	
	IF ShipFlag = '1' AND WfrID  NE '' THEN
		ShipCnt += 1
		ShipWfrIDs<1,ShipCnt> = WfrID
	END
NEXT I

AvailSlots = obj_WO_Mat_Wfr('GetPostEpiSlots',WONo)

ShipSlots = FIELD(AvailSlots,@FM,1,ShipCnt)

CONVERT @FM TO @VM IN ShipSlots

OutCtrl = @WINDOW:'.OUTBOUND_SLOTS'

OutArray = Get_Property(OutCtrl,'DEFPROP')


OutArray<COL$OUT_SLOT_ID>	= ShipSlots
OutArray<COL$OUT_WFR_ID>	= ShipWfrIDs
OutArray<COL$OUT_SCRIBE>	= XLATE('WO_WFR',ShipWfrIDs,12,'X')	;* Scribes on WO_WFR table records

Set_Property(OutCtrl,'DEFPROP',OutArray)

RETURN


* * * * * * *
UnloadWafers:
* * * * * * *

RDSNo = Get_Property(@WINDOW:'.RDS_NO','DEFPROP')

ShipArray = Get_Property(@WINDOW:'.OUTBOUND_SLOTS','DEFPROP')

ShipSlots 	= ShipArray<COL$OUT_SLOT_ID>
ShipWfrs	= ShipArray<COL$OUT_WFR_ID>


Send_Event(@WINDOW,'WRITE')

obj_React_Run('ShipGANWfrs',RDSNo:@RM:ShipSlots:@RM:ShipWfrs)

IF Get_Status(errCode) THEN
	ErrMsg(errCode)
END

obj_Appwindow('LUValReturn',RDSNo:@RM:@WINDOW:'.RDS_NO':@RM)

RETURN


* * * * * * *
CarrOptions:
* * * * * * *

CtrlEntID = @WINDOW:'.CARR_WFRS'

CarrList = Get_Property(CtrlEntID,'LIST')

CurrPos = Get_Property(CtrlEntID,'NOTIFYPOS')	;* Undocumented property that gives cell location when multi select is enabled.
CurrCol = CurrPos<1>
CurrRow = CurrPos<2>

IF CurrCol = COL$CARR_GRADE THEN
	
	WfrGrade = Popup(@WINDOW,'','GAN_WFR_GRADE')
	
	IF WfrGrade = CHAR(27) THEN RETURN
	
	obj_Appwindow('LUValReturn',WfrGrade:@RM:CtrlEntID:@RM:COL$CARR_GRADE:@FM:CurrRow)
	
END


RETURN


* * * * * * *
RejMat:
* * * * * * *

CarrCtrl = @WINDOW:'.CARR_WFRS'

CarrSlotList = Get_Property(CarrCtrl,'LIST')

SlotSelection	= Get_Property(CarrCtrl,'SELPOS')
SelectedRows	= SlotSelection<2>

CONVERT @VM TO @FM in SelectedRows

SelCnt		= COUNT(SelectedRows,@FM) + (SelectedRows NE '')
IF SelCnt	= 0 THEN
	ErrMsg('You must select at least one row in order to create an NCR.')
	RETURN
END

Ctrls  = @WINDOW:'.WO_NO':@RM			; Props  = 'DEFPROP':@RM
Ctrls := @WINDOW:'.RDS_NO':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.REACTOR':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.NCR_KEYS'			; Props := 'DEFPROP'

Vals = Get_Property(Ctrls,Props)

WONo		= Vals[1,@RM]
RDSNo		= Vals[COL2()+1,@RM]
Reactor		= Vals[COL2()+1,@RM]
NCRArray	= Vals[COL2()+1,@RM]

RejWfrIDs	= ''
RejSlotIDs	= ''

GoodLines = 0
FOR I = 1 TO SelCnt
	SlotNo = SelectedRows<I>
	IF CarrSlotList<SlotNo,COL$CARR_WFR_ID> NE '' Then
		GoodLines += 1
		RejWfrIDs<1,GoodLines> 		= CarrSlotList<SlotNo,COL$CARR_WFR_ID>
		RejSlotIDs<1,GoodLines>		= RDSNo:'*':SlotNo
	END
NEXT I

ncrParms  = WONo:@RM
ncrParms := '1':@RM
ncrParms := '':@RM					;* Place holder for WO_MAT_CASS_NO
ncrParms := RDSNo:@RM				;* Single RDS field 
ncrParms := Reactor:@RM				;* Reactor No
ncrParms := '':@RM					;* Loss Stage
ncrParms := RejWfrIDs:@RM			;* WfrIDs			;* CarrWafer IDs
ncrParms := RejSlotIDs:@RM			;* CarrSlotIDs		;* GaN PostEpi Carrier Slot ID	-> GaN non-characterization wafers
ncrParms := '':@RM					;* CassSlotIDs		;* WOMat Cassette Slot ID		-> Rej from cassette
ncrParms := ''						;* RunPocketZone	;* RPZ							-> Rej from susceptor

Set_Status(0)
NCRNo = obj_NCR('CreateWfr',ncrParms)		;* Create new NCR for this wafer/group of wafers

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

	RejDTM = OCONV(Date(),'D4/'):' ':OCONV(Time(),'MTS')

	sCnt = COUNT(RejSlotIDs,@VM) + (RejSlotIDs NE '')
	FOR N = 1 TO sCnt
	
		RowNo = SelectedRows<N>
		
		Set_Property(CarrCtrl,'CELLPOS',NCRNo,COL$CARR_NCR:@FM:RowNo)				;* Add NCR number to cell
	NEXT N
END

Set_Property(@WINDOW:'.CARR_WFRS','SELPOS',SlotSelection)	;* Toggle CARR_WFR selection off


NCRNos = NCRArray<COL$NCR_NO>								;* Added 6/17/2010 JCH fixes bug NCR sigs being on the wrong line or just hanging

LOOP
UNTIL NCRNos[-1,'B':@VM] NE '' OR NCRNos = ''
	NCRNos[-1,1] = ''
REPEAT

LOCATE NCRNo IN NCRNos BY 'AR' USING @VM SETTING Pos ELSE
	NCRArray = INSERT(NCRArray,COL$NCR_FIN_SIG,Pos,0,'')
	NCRArray = INSERT(NCRArray,COL$NCR_FIN_SIG_DTM,Pos,0,'')
END

*Set_Property('WO_MAT_WFR.NCR_KEYS','DEFPROP',NCRArray)		;* End of 6/17/2010 update

Set_Property(@WINDOW,'@SKIP_WRITE_UPDATE',1)				;* Set flag to stop window from closing and updating the WO_WFR records

Send_Event(@WINDOW,'WRITE')

DetWindow	= 'NCR'
DetKeys		= NCRNo
DefaultRec	= ''
RetKey		= RDSNo
RetWin		= 'REACT_RUN_DISP'
RetPage		= 1
RetCtrl		= @WINDOW:'.CARR_WFRS'
RetPos		= 1:@FM:1

obj_Appwindow('ViewNewDetail',DetWindow:@RM:DetKeys:@RM:DefaultRec:@RM:RetKey:@RM:RetPage:@RM:RetCtrl:@RM:RetPos)

IF Get_Status(errCode) THEN 
	Errmsg(errCode)
END


RETURN


* * * * * * *
CharWfrsDC:
* * * * * * *

RDSNo = Get_Property(@WINDOW:'.RDS_NO','DEFPROP')

IF RDSNo = '' THEN RETURN

CtrlEntID = @WINDOW:'.CHAR_WFRS'

CurrList = Get_Property(CtrlEntID,'LIST')

CurrPos	= Get_Property(CtrlEntID,'NOTIFYPOS')
CurrCol	= CurrPos<1>
CurrRow	= CurrPos<2>


BEGIN CASE

	CASE CurrCol = COL$CHAR_WFR_ID
		* Wafer History Popup


	CASE CurrCol = COL$CHAR_TW_NO
		TWNo = CurrList<CurrRow,COL$CHAR_TW_NO>
		
		IF TWNo NE '' THEN 		
			DetWindow	= 'TEST_WAFER'
			DetKeys		= TWNo
			DefaultRec	= ''
			RetKey		= RDSNo
			RetPage		= 1
			RetCtrl		= CtrlEntID
			RetPos		= CurrPos
			
			oAParms = DetWindow:@RM:DetKeys:@RM:DefaultRec:@RM:RetKey:@RM:RetPage:@RM:RetCtrl:@RM:RetPos

			obj_AppWindow('ViewNewDetail',oAParms)
			IF Get_Status(errCode) THEN
				ErrMsg(errCode)
			END
		END
		
END CASE

RETURN


* * * * * * *
NCRKeysDC:
* * * * * * *

RDSNo = Get_Property(@WINDOW:'.RDS_NO','TEXT')
CtrlEntID = @WINDOW:'.NCR_KEYS'

CurrPos = Get_Property(CtrlEntID,'SELPOS')
CurrCol = CurrPos<1>
CurrRow = CurrPos<2>

NCRKey = Get_Property(CtrlEntID,'CELLPOS',1:@FM:CurrRow)

IF NCRKey = '' THEN RETURN

Set_Property(@WINDOW,'@SKIP_WRITE_UPDATE',1)

Send_Event(@WINDOW,'WRITE')

DetWindow	= 'NCR'
DetKeys		= NCRKey
DefaultRec	= ''
RetKey		= RDSNo
RetWin		= @WINDOW
RetPage		= 1
RetCtrl		= CtrlEntID
RetPos		= CurrPos

obj_Appwindow('ViewNewDetail',DetWindow:@RM:DetKeys:@RM:DefaultRec:@RM:RetKey:@RM:RetPage:@RM:RetCtrl:@RM:RetPos)

RETURN



* * * * * * *
CarrWfrsDC:
* * * * * * *

RDSNo = Get_Property(@WINDOW:'.RDS_NO','DEFPROP')

IF RDSNo = '' THEN RETURN

CtrlEntID = @WINDOW:'.CARR_WFRS'

CurrList = Get_Property(CtrlEnTID,'LIST')

CurrPos	= Get_Property(CtrlEntID,'NOTIFYPOS')
CurrCol	= CurrPos<1>
CurrRow	= CurrPos<2>

BEGIN CASE
	CASE CurrCol = COL$CARR_NCR
		NCRNo = CurrList<CurrRow,COL$CARR_NCR>
		
		IF NCRNo NE '' THEN

			*Send_Event('REACT_RUN_DISP','WRITE')

			DetWindow	= 'NCR'
			DetKeys		= NCRNo
			DefaultRec	= ''
			RetKey		= RDSNo
			RetPage		= 1
			RetCtrl		= CtrlEntID
			RetPos		= CurrPos

			obj_Appwindow('ViewNewDetail',DetWindow:@RM:DetKeys:@RM:DefaultRec:@RM:RetKey:@RM:RetPage:@RM:RetCtrl:@RM:RetPos)
			
		END
		
END CASE

RETURN


***********
CarrWfrsPC:
***********

RDSNo = Get_Property(@WINDOW:'.RDS_NO','DEFPROP')

IF (RDSNo NE '') THEN

	CtrlEntID = @WINDOW:'.CARR_WFRS'

	CurrList = Get_Property(CtrlEnTID, 'LIST')

	CurrPos	= Get_Property(CtrlEntID, 'NOTIFYPOS')
	CurrCol	= CurrPos<1>
	CurrRow	= CurrPos<2>
	
	PrevPos = Get_Property(CtrlEntID, 'PREVSELPOS')
	PrevCol	= PrevPos<1>
	PrevRow	= PrevPos<2>
	
	Scribe     = CurrList<CurrRow, COL$CARR_SCRIBE>
	RetainFlag = CurrList<CurrRow, COL$CARR_RETAIN_WFR>
	ShipFlag   = CurrList<CurrRow, COL$CARR_WFR_SHIP>

	RemoveFocus = true$
	IF (Scribe NE '') then
		IF ((CurrCol = COL$CARR_RET_CASS_ID) OR (CurrCol = COL$CARR_RET_SLOT)) THEN
			IF ((RetainFlag = 1) OR (RetainFlag = 'Yes')) THEN
				/* Move the focus to the Retain Wafer ID field */
				Set_Property(CtrlEntID, 'CARETPOS', CurrPos)
				/* Keep focus on that edit table cell */
				RemoveFocus = false$
			END
		
		end else
			IF ((CurrCol = COL$CARR_RETAIN_WFR) OR (CurrCol = COL$CARR_WFR_SHIP) OR (CurrCol = COL$CARR_GRADE)) THEN
				RemoveFocus = false$
			end
		END
	END
	
	IF (RemoveFocus = true$) then
		Set_Property("SYSTEM", "BLOCK_EVENTS", true$)
		Set_Property(CtrlEntID, 'SELPOS', PrevPos)
		Handle = Get_Property(CtrlEntID, 'HANDLE')
		CALL sendMessage(Handle, DTM_SELROW$, 0, PrevRow-1)
		Set_Property("SYSTEM", "BLOCK_EVENTS", false$)
	END

END ;* End of Check for RDS Number

RETURN


* * * * * * *
CarrWfrsClick:
* * * * * * *

RDSNo = Get_Property( @WINDOW:'.RDS_NO','DEFPROP')

IF (RDSNo NE '') THEN

	CtrlEntID = @WINDOW:'.CARR_WFRS'

	CurrList = Get_Property(CtrlEnTID,'LIST')

	CurrPos	= Get_Property(CtrlEntID,'NOTIFYPOS')
	CurrCol	= CurrPos<1>
	CurrRow	= CurrPos<2>

	Scribe = CurrList<CurrRow, COL$CARR_SCRIBE>

	IF (Scribe NE '') THEN

		ShipFlag   = CurrList<CurrRow, COL$CARR_WFR_SHIP>
		RetainFlag = CurrList<CurrRow, COL$CARR_RETAIN_WFR>

		BEGIN CASE

			CASE CurrCol = COL$CARR_WFR_SHIP

				/* Request to ship */
				IF ((ShipFlag = 1) OR (ShipFlag = 'Yes')) THEN
					
					IF (CurrList<CurrRow, COL$CARR_RET_CASS_ID> = '') AND (CurrList<CurrRow, COL$CARR_RET_SLOT> = '') THEN
					
						IF ((RetainFlag = 1) OR (RetainFlag = 'Yes')) THEN
							Set_Property(CtrlEntID, 'CELLPOS', False, COL$CARR_RETAIN_WFR:@FM:CurrRow)
							*ErrMsg('PATH #1')
							
						END ELSE
							/* Move the "Carrier Wafer ID" to the "Previous Carrier Wafer ID" */
							WaferID = CurrList<CurrRow,COL$CARR_WFR_ID>
							Set_Property(CtrlEntID, 'CELLPOS', WaferID, COL$CARR_PREV_WFR_ID:@FM:CurrRow)
							Set_Property(CtrlEntID, 'CELLPOS', '', COL$CARR_WFR_ID:@FM:CurrRow)
							*ErrMsg('PATH #2')
						END

						Set_Property(CtrlEntID, 'CELLPOS', True, COL$CARR_WFR_SHIP:@FM:CurrRow)
						Set_Property(CtrlEntID, 'CELLPOS', 1,    COL$CARR_WFR_SHIP:@FM:CurrRow)

					END ELSE
						Set_Property(CtrlEntID, 'CELLPOS', False, COL$CARR_WFR_SHIP:@FM:CurrRow)
						ErrMsg('WARNING! This wafer has already been retained.')
						*ErrMsg('PATH #3')
					END
					
				/* Request to un-ship */
				END ELSE
					IF (CurrList<CurrRow, COL$CARR_SHIP_ID> = '') THEN
						/* Un-Mark wafer to be shipped */
						Set_Property(CtrlEntID, 'CELLPOS', False, COL$CARR_WFR_SHIP:@FM:CurrRow)

						/* Move the "Previous Carrier Wafer ID" to the "Carrier Wafer ID" */
						PrevWaferID = CurrList<CurrRow,COL$CARR_PREV_WFR_ID>
						Set_Property(CtrlEntID, 'CELLPOS', PrevWaferID, COL$CARR_WFR_ID:@FM:CurrRow)
						Set_Property(CtrlEntID, 'CELLPOS', '', COL$CARR_PREV_WFR_ID:@FM:CurrRow)
						*ErrMsg('PATH #4')
						
					END ELSE
						Set_Property(CtrlEntID, 'CELLPOS', True, COL$CARR_WFR_SHIP:@FM:CurrRow)
						Set_Property(CtrlEntID, 'CELLPOS', 1,    COL$CARR_WFR_SHIP:@FM:CurrRow)
						ErrMsg('WARNING! This wafer has already been shipped.')
						*ErrMsg('PATH #5')
					END
				END
				
			CASE CurrCol = COL$CARR_RETAIN_WFR
				
				/* Request to retain a wafer */
				IF ((RetainFlag = 1) OR (RetainFlag = 'Yes')) THEN
					
					IF (CurrList<CurrRow, COL$CARR_SHIP_ID> = '') THEN

						IF ((ShipFlag = 1) OR (ShipFlag = 'Yes')) THEN
							Set_Property(CtrlEntID, 'CELLPOS', False, COL$CARR_WFR_SHIP:@FM:CurrRow)
							*ErrMsg('PATH #6')

						END ELSE
							/* Move the "Carrier Wafer ID" to the "Previous Carrier Wafer ID" */
							WaferID = CurrList<CurrRow,COL$CARR_WFR_ID>
							Set_Property(CtrlEntID, 'CELLPOS', WaferID, COL$CARR_PREV_WFR_ID:@FM:CurrRow)
							Set_Property(CtrlEntID, 'CELLPOS', '', COL$CARR_WFR_ID:@FM:CurrRow)
							*ErrMsg('PATH #7')
						END
						
						Set_Property(CtrlEntID, 'CELLPOS', True,  COL$CARR_RETAIN_WFR:@FM:CurrRow)
						Set_Property(CtrlEntID, 'CELLPOS', 1,     COL$CARR_RETAIN_WFR:@FM:CurrRow)

						/* Move the focus to the Retain Wafer ID field */
						Set_Property(CtrlEntID, 'CARETPOS', COL$CARR_RET_CASS_ID:@FM:CurrRow)
						
					END ELSE
						Set_Property(CtrlEntID, 'CELLPOS', False, COL$CARR_RETAIN_WFR:@FM:CurrRow)
						ErrMsg('WARNING! This wafer has already been shipped.')
						*ErrMsg('PATH #8')
					END
					
				/* Request to un-retain a wafer */
				END ELSE

					IF (CurrList<CurrRow, COL$CARR_RET_CASS_ID> = '') AND (CurrList<CurrRow, COL$CARR_RET_SLOT> = '') THEN
						/* Un-Mark wafer to be retained */
						Set_Property(CtrlEntID, 'CELLPOS', False, COL$CARR_RETAIN_WFR:@FM:CurrRow)

						/* Move the "Previous Carrier Wafer ID" to the "Carrier Wafer ID" */
						PrevWaferID = CurrList<CurrRow,COL$CARR_PREV_WFR_ID>
						Set_Property(CtrlEntID, 'CELLPOS', PrevWaferID, COL$CARR_WFR_ID:@FM:CurrRow)
						Set_Property(CtrlEntID, 'CELLPOS', '', COL$CARR_PREV_WFR_ID:@FM:CurrRow)
						*ErrMsg('PATH #9')

					END ELSE
						Set_Property(CtrlEntID, 'CELLPOS', True, COL$CARR_RETAIN_WFR:@FM:CurrRow)
						Set_Property(CtrlEntID, 'CELLPOS', 1,    COL$CARR_RETAIN_WFR:@FM:CurrRow)
						ErrMsg('WARNING! This wafer has already been retained.')
						*ErrMsg('PATH #10')
					END
				END
				
		END CASE

	END ELSE
		Set_Property(CtrlEntID, 'CELLPOS', False, COL$CARR_RETAIN_WFR:@FM:CurrRow)
		Set_Property(CtrlEntID, 'CELLPOS', False, COL$CARR_WFR_SHIP:@FM:CurrRow)
		
	END

END

RETURN


* * * * * * *
ReturnChar:
* * * * * * *

RDSNo = Get_Property(@WINDOW:'.RDS_NO','DEFPROP')

RDSRec = Get_Property(@WINDOW,'RECORD')

CtrlEntID	= @WINDOW:'.CHAR_WFRS'

CurrPos = Get_Property(CtrlEntID,'SELPOS')
CurrCol = CurrPos<1>
CurrRow = CurrPos<2>

CharWfrList = Get_Property(CtrlEntID,'LIST')

WfrID			= CharWfrList<CurrRow,COL$CHAR_WFR_ID>
WfrDestroyed	= CharWfrList<CurrRow,COL$CHAR_DESTROYED>
WfrTWNo			= CharWfrList<CurrRow,COL$CHAR_TW_NO>

IF WfrID = '' THEN RETURN

BEGIN CASE
	*CASE WfrDestroyed NE '' 	; *ErrorMsg = 'Wafer has been through destructive test.'
	CASE WfrTWNo NE ''			; ErrorMsg = 'Wafer has been recorded on a TW Use record.'
END CASE

IF ErrorMsg NE '' THEN RETURN

Send_Event(@WINDOW,'WRITE')

CurrInvLoc 	= XLATE('WO_WFR',WfrID,'CURR_LOC_ID','X')
CurrTool	= XLATE('WO_WFR',WfrID,'CURR_TOOL','X')
CarrSlotID	= XLATE('WO_WFR',WfrID,'CARR_SLOT_ID','X')

CurrDTM =  OCONV(Date(),'D4/'):' ':OCONV(Time(),'MTS')

owwParms	 = WfrID:@RM					;* WfrIDs - mv
owwParms	:= CurrDTM:@RM					;* EventDtm
owwParms	:= @USER4:@RM					;* EventBy
owwParms	:= 'UNSPLIT':@RM				;* Event
owwParms	:= '':@RM						;* New Slot IDs - mv
owwParms	:= '':@RM						;* RPZs(RDSNo*Pocket*Zone)s - mv
owwParms	:= '':@RM						;* NCRNo
owwParms	:= '':@RM						;* TWUse ID 
owwParms	:= '':@RM						;* Current Slot ID - mv
owwParms	:= '':@RM						;* New ToolID
owwParms	:= CurrTool:@RM					;* Curr Tool ID
owwParms 	:= '':@RM						;* NewInvLoc
owwParms	:= CurrInvLoc:@RM				;* CurrInvLoc		;* This is needed
owwParms 	:= 'O':@RM						;* Wfr Side
owwParms	:= CarrSlotID:@RM				;* NewCarrLoc
owwParms	:= ''							;* CurrCarrLoc		;* Not currently used			

obj_WO_Wfr('AddEvent',owwParms)				;* Takes Carrier Loc off and Adds QIn for first Char step

IF Get_Status(errCode) THEN
	ErrMsg(errCode)
END

obj_React_Run('UnSplitWfr',RDSNo:@RM:WfrID)	;* Moves WfrID from <REACT_RUN_PREV_CARR_WFR_ID$> TO <REACT_RUN_CARR_WFR_ID$>

Set_Property(@WINDOW:'.RDS_NO','DEFPROP',RDSNo,'X')

Post_Event(@WINDOW,'READ')

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


*********
TrapKeys:
*********

	Message = Parm2

	BEGIN CASE

	   CASE ( Message = ETM_INSERTROW$ )
			* // Stop the insert here...
			CALL set_WinMsgVal( TRUE$, 0 )  ; * // Force PS to return 0 to Windows

	   CASE ( Message = ETM_DELETEROW$ )
			* // Stop the delete here...
			CALL set_WinMsgVal( TRUE$, 0 )  ; * // Force PS to return 0 to Windows

	END CASE

RETURN 

