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

/*
	Commuter module for existing RDS... windows.
	Used for added functionality in the RDS Mess.
	
	09/17/2004 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Send_Event, Set_Status, ErrMsg, Security_Err_Msg, Popup, Print_Cass_Labels
DECLARE SUBROUTINE obj_Appwindow, Start_Window, Btree.Extract, Msg, Start_Window,Print_Cleanroom_Labels_Thermal,obj_WO_Mat_Log, obj_Post_Log
DECLARE SUBROUTINE obj_RDS_Test, obj_Notes, Print_Control_Plan, obj_WO_Mat, Send_Event, Print_RDS_Instruction, obj_RDS, obj_Tables, obj_React_Run, Post_Event
DECLARE SUBROUTINE Start_Window

DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Utility, Send_Message, Popup, obj_RDS_Makeup, Msg, obj_RDS, obj_Tables, obj_Clean_Insp, obj_WO_Mat_QA
DECLARE FUNCTION obj_WO_Step, Security_Check, obj_RDS_Audit, obj_WM_In, Create_Dialog, obj_NCR, obj_WO_Mat, MemberOf, obj_RDS_Test, obj_WO_Mat
DECLARE FUNCTION Start_Window, Database_Services

EQU CRLF$	TO \0D0A\

$INSERT APPCOLORS
$INSERT MSG_EQUATES
$INSERT POPUP_EQUATES
$INSERT RDS_EQU
$INSERT WO_STEP_EQU
$INSERT WO_LOG_EQUATES
$INSERT SECURITY_RIGHTS_EQU
$INSERT SEC_GROUPS_EQU
$INSERT DICT_EQUATES
$INSERT NOTIFICATION_EQU
$INSERT RDS_EPILOAD					;* Equates for data coming back from the EpiPRO Load/Unload dialog boxes
$INSERT LSL_USERS_EQU
$INSERT PROD_SPEC_EQU
$INSERT WO_MAT_EQUATES
$INSERT REACTOR_EQUATES
$INSERT CLEAN_INSP_EQUATES
$INSERT TOOL_CLASS_EQUATES
$INSERT QUOTE_SIGS_EQU
$INSERT COMPANY_EQUATES
$insert logical
$INSERT PRS_STAGE_EQUATES


EQU COL$LOG_FILE		TO 1		;* obj_WO_Mat_Log method parameter equates
EQU COL$LOG_DTM 		TO 2
EQU COL$WO_MAT_ACTION	TO 3
EQU COL$WH_CD			TO 4
EQU COL$LOC_CD			TO 5
EQU COL$WO_NOS			TO 6
EQU COL$CASS_NOS		TO 7
EQU COL$USER_ID			TO 8
EQU COL$TAGS			TO 9
EQU COL$TOOL_ID			TO 10

EQU FONT_FACE_NAME$			TO 1
EQU FONT_HEIGHT$			TO 2
EQU FONT_WEIGHT$			TO 3
EQU FONT_ITALIC$			TO 4
EQU FONT_UNDERLINE$			TO 5
EQU FONT_WIDTH$				TO 6
EQU FONT_CHAR_SET$			TO 7
EQU FONT_PITCH_AND_FAMILY$	TO 8
EQU FONT_STRIKE_OUT$		TO 9
EQU FONT_OUT_PRECISION$		TO 10
EQU FONT_CLIP_PRECISION$	TO 11
EQU FONT_QUALITY$			TO 12

EQU COL$LSID			TO 1
EQU COL$RECIPE			TO 2
EQU COL$RECIPE_NAME		TO 3
EQU COL$PARAMS			TO 4
EQU COL$PARMS_OUT		TO 5
EQU COL$BLANK_COL		TO 6
EQU COL$MET_NO			TO 7
EQU COL$THICK_AVG		TO 8
EQU COL$RRHO_AVG		TO 9
EQU COL$MET_NO_Z1		TO 10
EQU COL$THICK_AVG_Z1	TO 11
EQU COL$RRHO_AVG_Z1		TO 12
EQU COL$MET_NO_Z2		TO 13
EQU COL$THICK_AVG_Z2	TO 14
EQU COL$RRHO_AVG_Z2		TO 15
EQU COL$MET_OUT			TO 16
EQU COL$MET_OUT_Z1		TO 17
EQU COL$MET_OUT_Z2		TO 18
EQU COL$MET_TWSIG		TO 19
EQU COL$MET_TWSIG_Z1	TO 20
EQU COL$MET_TWSIG_Z2	TO 21

EQU COL$POCKET			TO 1
EQU COL$USE				TO 2
EQU COL$ZONE			TO 3
EQU COL$IN_CASS			TO 4
EQU COL$IN_SLOT			TO 5
EQU COL$CHAR			TO 6
EQU COL$OUT_CASS		TO 7
EQU COL$OUT_SLOT		TO 8
EQU COL$NCR				TO 9		;* Dead?

EQU COL$MET_TEST		TO 1		;* QA Metrology control RDS_POST_EPI window
EQU COL$MET_TEST_DESC	TO 2
EQU COL$MET_SLOT		TO 3
EQU COL$MET_SLOT_DESC	TO 4
EQU COL$MET_WFR_QTY		TO 5
EQU COL$MET_MIN			TO 6
EQU COL$MET_MAX			TO 7
EQU COL$MET_RESULT		TO 8
EQU COL$MET_STD_MAX		TO 9
EQU COL$MET_STD_RESULT	TO 10
EQU COL$MET_SIG			TO 11
EQU COL$MET_SIG_DTM		TO 12

EQU COL$UL_MET_TEST		    TO 1		;* QA Metrology control on RDS_UNLOAD window
EQU COL$UL_MET_TEST_DESC	TO 2
EQU COL$UL_MET_RECIPE       TO 3
EQU COL$UL_MET_SLOT		    TO 4
EQU COL$UL_MET_SLOT_DESC	TO 5
EQU COL$UL_MET_WFR_QTY		TO 6
EQU COL$UL_MET_MIN			TO 7
EQU COL$UL_MET_MAX			TO 8
EQU COL$UL_MET_RESULT		TO 9
EQU COL$UL_MET_PHASE_MIN    TO 10
EQU COL$UL_MET_PHASE_RESULT TO 11
EQU COL$UL_MET_SIG			TO 12
EQU COL$UL_MET_SIG_DTM		TO 13

EQU COL$HOLD_START_DTM		TO 1
EQU COL$HOLD_START_USER		TO 2
EQU COL$HOLD_START_REASON	TO 3
EQU COL$HOLD_STOP_DTM		TO 4
EQU COL$HOLD_STOP_USER		TO 5
EQU COL$HOLD_STOP_REASON	TO 6

EQU COL$ACTION				TO 1
EQU COL$SPEC_CLEAN_TOOL		TO 2
EQU COL$SPEC_MICROSCOPE		TO 3
EQU COL$SPEC_BRIGHTLIGHT	TO 4
EQU COL$SURFSCAN_RECIPE		TO 5
EQU COL$TOOL				TO 6
EQU COL$SIG					TO 7
EQU COL$SIG_DTM				TO 8

ErrTitle = 'Error in Comm_RDS'
ErrorMsg = ''

Result = ''

BEGIN CASE
	CASE Method = 'Clear'				; GOSUB Clear
	CASE Method = 'Refresh'				; GOSUB Refresh
	CASE Method = 'GotFocus'			; GOSUB GotFocus
	CASE Method = 'RdsLF'				; GOSUB RdsLF
	CASE Method = 'MUWafers'			; GOSUB MUWafers
	CASE Method = 'ProdWfrLF'			; GOSUB ProdWfrLF
	CASE Method = 'WafersInLF'			; GOSUB WafersInLF
	CASE Method = 'Update'				; GOSUB Update
	CASE Method = 'FirstRead'			; GOSUB FirstRead
	CASE Method = 'FirstRefresh'		; GOSUB FirstRefresh
	CASE Method = 'SupVerSigLF'			; GOSUB SupVerSigLF
	CASE Method = 'NewNCR'				; GOSUB NewNCR
	CASE Method = 'NCRKeysDC'			; GOSUB NCRKeysDC
	CASE Method = 'PrintLabels'			; GOSUB PrintLabels
	CASE Method = 'ViewAudit'			; GOSUB ViewAudit
	CASE Method = 'LSIdDC'				; GOSUB LSIdDC
	CASE Method = 'LoadEpiPro'			; GOSUB LoadEpiPro
	CASE Method = 'UnloadEpiPro'		; GOSUB UnloadEpiPro
	CASE Method = 'ClearEpiUnload'		; GOSUB ClearEpiUnload
	CASE Method = 'AddZoneMet'			; GOSUB AddZoneMet
	CASE Method = 'MoveMetToZone'		; GOSUB MoveMetToZone
	CASE Method = 'HoldClick'			; GOSUB HoldClick
	CASE Method = 'HoldDC'				; GOSUB HoldDC
	CASE Method = 'CtrlPlanClick'		; GOSUB CtrlPlanClick
	CASE Method = 'Override'			; GOSUB Override
	CASE Method = 'PrintInstruction'	; GOSUB PrintInstruction
	CASE Method = 'ViewWOMat'			; GOSUB ViewWOMat
	CASE Method = 'NextStepQty'			; GOSUB NextStepQty
	CASE Method = 'CIClick'				; GOSUB CIClick
	CASE Method = 'LoadCI'				; GOSUB LoadCI
	CASE Method = 'SAPSign'				; GOSUB SAPSign
	CASE Method = 'SAPReject'			; GOSUB SAPReject
	CASE Method = 'MetTestDC'			; GOSUB MetTestDC
	CASE Method = 'LUPostCode'			; GOSUB LUPostCode
	CASE Method = 'SigProfile'			; GOSUB SigProfile
	CASE Method = 'ReactProfile'		; GOSUB ReactProfile
	CASE 1
		ErrMsg(ErrTitle:@SVM:'Unknown method ':QUOTE(Method):' passed to routine.')
		
END CASE


RETURN Result


* * * * * * * 
RdsLF:
* * * * * * *


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

IF RDSNo NE '' THEN

	IF RowExists('RDS',RDSNo) ELSE
		Msg(@WINDOW,'','INVALID_RDS_NO')
	
	END
	
END	;* End of check for null RDSNo
	

RETURN


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




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

**** Added 4/9/2014 JCH * * * * * * 

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


IF WONo NE ''  THEN
	PriDisp = XLATE('WO_LOG',WONo,'PRI_DISPLAY','X')
	
	Set_Property(@WINDOW:'.PRI_DISPLAY_TEXT','TEXT',PriDisp)

	CurrFontProp = Get_Property(@WINDOW:'.PRI_DISPLAY_TEXT','FONT')

	NewFontProp = FIELD(CurrFontProp,@SVM,1,12)

	IF PriDisp[1,2] = 'P1' THEN
		Set_Property(@WINDOW:'.PRI_DISPLAY_TEXT','DEFPROP','P1 - High')
		NewFontProp<1,1,FONT_WEIGHT$> = 700
		NewFontProp<1,1,FONT_ITALIC$> = 255
		NewFontProp<1,1,FONT_WIDTH$> = 7
		ForeColor = BRED$
		
	END

	IF PriDisp[1,2] = 'P2' THEN
		Set_Property(@WINDOW:'.PRI_DISPLAY_TEXT','DEFPROP','P2 - Medium')
		NewFontProp<1,1,FONT_WEIGHT$> = 400
		NewFontProp<1,1,FONT_ITALIC$> = 255
		NewFontProp<1,1,FONT_WIDTH$> = 6
		ForeColor = BYELLOW$
	END	

	IF PriDisp[1,2] = 'P3' THEN
		Set_Property(@WINDOW:'.PRI_DISPLAY_TEXT','DEFPROP','P3 - Low')
		NewFontProp<1,1,FONT_WEIGHT$> = 400
		NewFontProp<1,1,FONT_ITALIC$> = 0
		NewFontProp<1,1,FONT_WIDTH$> = 6
		ForeColor = FONTGREEN$
		
	END

	Set_Property(@WINDOW:'.PRI_DISPLAY_TEXT','FONT', NewFontProp)
	Set_Property(@WINDOW:'.PRI_DISPLAY_TEXT','FORECOLOR',ForeColor)
END	;* End of check for window



* * * * * * ** * * * *


PSNo = Get_Property(@WINDOW:'.PSN','TEXT')
PSStatus = XLATE('PROD_SPEC',PSNo,9,'X')

IF PSStatus[1,1] = 'I' THEN
	Set_Property(@WINDOW:'.PSN','BACKCOLOR',RED$)
END ELSE
	Set_Property(@WINDOW:'.PSN','BACKCOLOR',GREEN$)
END

IF MemberOf(@USER4,'TESTING') OR @USERNAME = 'BRYCE_BARB' OR @USER4 = 'BRYCE_BARB' THEN
	
	BEGIN CASE
		CASE @WINDOW = 'RDS_PRE_EPI'
			Set_Property(@WINDOW:'.PRE_CI_NO','VISIBLE',1)
			
		CASE @WINDOW = 'RDS'
			Set_Property(@WINDOW:'.FWI_CI_NO','VISIBLE',1)
			
		CASE @WINDOW = 'RDS_UNLOAD'
			Set_Property(@WINDOW:'.LWI_CI_NO','VISIBLE',1)
				
		CASE @WINDOW = 'RDS_POST_EPI'
			Set_Property(@WINDOW:'.POST_CI_NO','VISIBLE',1)
		
	END CASE
END

* Modification History Button

ProdMgr = XLATE( 'CONFIG', 'QUOTE_SIGS', ProdMgr$, 'X' )
TrainSpec = XLATE( 'CONFIG', 'QUOTE_SIGS', TrainSpec$, 'X' )

IF  @USERNAME = 'BRYCE_BARB' OR (Memberof( @USER4, 'MASTER' )) OR ( @USER4 = ProdMgr ) OR ( @USER4 = TrainSpec ) THEN
	Set_Property( @WINDOW:'.VIEW_MOD_HIST', 'VISIBLE', 1 )
END


* Wafers Accounting and update section

UseMUWafers		= Get_Property(@WINDOW:'.MU_WAFERS_FLAG','CHECK')
MakeupBox		= Get_Property(@WINDOW:'.MAKEUP_BOX','CHECK')
WafersIn		= Get_Property(@WINDOW:'.WAFERS_IN','INVALUE')
WafersOut		= Get_Property(@WINDOW:'.WAFERS_OUT','INVALUE')
WafersScheduled = Get_Property(@WINDOW:'.WAFERS_SCHEDULED','INVALUE')
WafersVerify	= Get_Property(@WINDOW:'.VERIFY_QTY','INVALUE')
WafersProdTest	= Get_Property(@WINDOW:'.TW_PROD','INVALUE')
WafersTotRej	= Get_Property(@WINDOW:'.TOT_REJ','INVALUE')
WafersSRPBill	= Get_Property(@WINDOW:'.RESEARCH_SRP_BILLABLE','INVALUE')
RunOrderNo		= Get_Property(@WINDOW:'.RUN_ORDER_NUM','INVALUE')
MUWfrsRemoved	= Get_Property(@WINDOW:'.MU_WFRS_REMOVED','INVALUE')
MUWfrsAdded		= Get_Property(@WINDOW:'.MU_WFRS_ADDED','INVALUE')
WONo			= Get_Property(@WINDOW:'.WO','INVALUE')
CassNo			= Get_Property(@WINDOW:'.CASS_NO','INVALUE')
CassSchedShip   = Get_Property(@WINDOW:'.CASS_SHIP_QTY', 'INVALUE')

CassShipQty     = XLATE('WO_MAT',WONo:'*':CassNo,WO_MAT_CASS_SHIP_QTY$,'X')
MinCassShipQty  = XLATE('WO_MAT',WONo:'*':CassNo,WO_MAT_MIN_CASS_SHIP_QTY$,'X')

IF CassShipQty NE '' AND CassShipQty > 0 THEN
	FullBoxQty = CassShipQty
END ELSE
	FullBoxQty = WafersIn
END

EnableLoadButton = 1
EnableQASignButton = 1
EnableUnloadButton = 1

QASignReason = ''

IF UseMUWafers THEN
	Set_Property(@WINDOW:'.MU_WAFER_BUTTON','VISIBLE',0)
	IF (WafersIn NE '' AND WafersOut NE ''  AND WafersOut < FullBoxQty) THEN
		IF RunOrderNo = 1 THEN
			IF MUWfrsRemoved NE '' THEN
				Set_Property(@WINDOW:'.MU_WAFER_BUTTON','ENABLED',0)	;* Rejects, needs makeup wafers** was 1 jch
			END ELSE
				Set_Property(@WINDOW:'.MU_WAFER_BUTTON','ENABLED',0)	;* was 1 jch
			END
		END ELSE
			Set_Property(@WINDOW:'.MU_WAFER_BUTTON','ENABLED',0)		;* was 1 jch
		END
	END ELSE
		IF MUWfrsRemoved NE '' OR MUWfrsAdded NE '' THEN
			Set_Property(@WINDOW:'.MU_WAFER_BUTTON','ENABLED',0)		;* was 1 jch
		END ELSE
			Set_Property(@WINDOW:'.MU_WAFER_BUTTON','ENABLED',0)	;* No rejects, doesn't need makeup wafers
		END
	END
END ELSE
	Set_Property(@WINDOW:'.MU_WAFER_BUTTON','VISIBLE',0)
END

BoxType = Get_Property(@WINDOW:'.BOX_TYPE','TEXT')

IF BoxType = 'Merged Lots' THEN
	Set_Property(@WINDOW:'.MU_WAFERS_ADDED','ENABLED',1)
	Set_Property(@WINDOW:'.MU_ADDED_LABEL','ENABLED',1)
END ELSE
	Set_Property(@WINDOW:'.MU_WAFERS_ADDED','ENABLED',0)
	Set_Property(@WINDOW:'.MU_ADDED_LABEL','ENABLED',0)
END


IF BoxType = 'Makeup Box' THEN
	Set_Property(@WINDOW:'.MU_WAFERS_REMOVED','ENABLED',1)
	Set_Property(@WINDOW:'.MU_REMOVED_LABEL','ENABLED',1)
END ELSE
	Set_Property(@WINDOW:'.MU_WAFERS_REMOVED','ENABLED',0)
	Set_Property(@WINDOW:'.MU_REMOVED_LABEL','ENABLED',0)
END

IF (WafersIn NE WafersScheduled) OR (WafersVerify NE WafersScheduled) THEN
    *Ctrls = @WINDOW:'.WAFERS_IN':@RM: @WINDOW:'.WAFERS_SCHEDULED':@RM:@WINDOW:'.VERIFY_QTY'
    *Props = 'BACKCOLOR':@RM:'BACKCOLOR':@RM:'BACKCOLOR'
    *Vals = RED$:@RM:RED$:@RM:RED$
    EnableQASignButton	= 0
    IF QASignReason = '' THEN QASignReason = 'Wafers In or Wafers Verified is not equal to Wafers Scheduled'
END ELSE
    *Ctrls = @WINDOW:'.WAFERS_IN':@RM: @WINDOW:'.WAFERS_SCHEDULED':@RM:@WINDOW:'.VERIFY_QTY'
    *Props = 'BACKCOLOR':@RM:'BACKCOLOR':@RM:'BACKCOLOR'
    *Vals = GREEN$:@RM:GREEN$:@RM:GREEN$
END

IF Get_Property(@WINDOW:'.HOT_LOT','CHECK') THEN
	Set_Property(@WINDOW:'.HOT_LOT_LABEL','VISIBLE',1)
END ELSE
	Set_Property(@WINDOW:'.HOT_LOT_LABEL','VISIBLE',0)
END

IF Get_Property(@WINDOW:'.HGCV_TEST_CHECK','CHECK') THEN
	Set_Property(@WINDOW:'.HGCV_TEST','VISIBLE',1)
END ELSE
	Set_Property(@WINDOW:'.HGCV_TEST','VISIBLE',0)
END

* * * * Pre Epi window

IF @WINDOW = 'RDS_PRE_EPI' THEN
	VerifyQty = Get_Property(@WINDOW:'.VERIFY_QTY','INVALUE')
	IF VerifyQty NE WafersScheduled THEN
		Ctrls = @WINDOW:'.VERIFY_QTY'
		Props = 'BACKCOLOR'
		Vals = RED$
	END ELSE
		Ctrls = @WINDOW:'.VERIFY_QTY'
		Props = 'BACKCOLOR'
		Vals = WHITE$
	END
	Set_Property(Ctrls,Props,Vals)
	
	IF Get_Property(@WINDOW:'.HOLD_CHECKBOX','CHECK') THEN
		Set_Property(@WINDOW:'.HOLD_BUTTON','TEXT','Remove Hold')
	END ELSE
		Set_Property(@WINDOW:'.HOLD_BUTTON','TEXT','Place on Hold')
	END
	
	IF MemberOf(@USER4, 'OI_ADMIN') THEN
		Set_Property(@WINDOW:'.FIX_SIG_PROFILE','VISIBLE',1)
	END ELSE
		Set_Property(@WINDOW:'.FIX_SIG_PROFILE','VISIBLE',0)
	END 
END

* * * * * Load / Wafer Inspection window

IF @WINDOW = 'RDS' THEN
	PSNo			= Get_Property(@WINDOW:'.PSN','TEXT')
	FirstWfrSig		= Get_Property(@WINDOW:'.FW_SIG','DEFPROP')
	WinBackColor	= Get_Property(@WINDOW,'BACKCOLOR')			;* default background color
	
	FirstOrLast = XLATE('PROD_SPEC',PSNo,PROD_SPEC_POST_FWI_LWI$,'X')
	IF FirstOrLast NE '' THEN
		IF FirstOrLast = 'FWI' THEN
			Set_Property(@WINDOW:'.GROUP_10','TEXT','FWI Surface Inspection Signature')
			Set_Property(@WINDOW:'.SURFACE_Q_BUTTON','TEXT','FWI Surface Inspection')
		END
		IF FirstOrLast = 'LWI' THEN
			Set_Property(@WINDOW:'.GROUP_10','TEXT','LWI Surface Inspection Signature')
			Set_Property(@WINDOW:'.SURFACE_Q_BUTTON','TEXT','LWI Surface Inspection')
		END
		IF FirstWfrSig = '' THEN
			Set_Property(@WINDOW:'.GROUP_10','BACKCOLOR',YELLOW$)
		END ELSE
			Set_Property(@WINDOW:'.GROUP_10','BACKCOLOR',WinBackColor)
		END
	END
	
	
END

* * * * * Unload Window

IF @WINDOW = 'RDS_UNLOAD' THEN

	Reactor = Get_Property(@WINDOW:'.REACTOR','DEFPROP')
	ReactorType = XLATE('REACTOR',Reactor,1,'X')
	IF ReactorType = 'EPP' THEN
		*Set_Property(@WINDOW:'.NEW_NCR','VISIBLE',0)
		Set_Property(@WINDOW:'.NCR_MU_BUTTON','VISIBLE',0)
	END ELSE
		*Set_Property(@WINDOW:'.NEW_NCR','VISIBLE',1)
		Set_Property(@WINDOW:'.NCR_MU_BUTTON','VISIBLE',1)
	END

	CtrlName = @WINDOW:'.NCR_KEYS'
	NCRList = Get_Property(CtrlName,'LIST')

	FOR Line = 1 TO COUNT(NCRList,@FM) + (NCRList NE '')
		Status = NCRList<Line,2>
		
		BEGIN CASE
			CASE Status = ''
				Color = WHITE$
				
			CASE Status = 'Closed'
				Color = GREEN$
				
			CASE Status = 'Open'
				Color = RED$
				EnableQASignButton	= 0
				IF QASignReason = '' THEN QASignReason = 'Open NCR'
				
			CASE Status = 'Verified'
				Color = YELLOW$
		
			CASE 1
				Color = WHITE$
			
		END CASE
		stat = Send_Message(CtrlName,'COLOR_BY_POS',0,Line,Color)

	NEXT Line

END

****************************************************************************************************************************************
// RDS and RDS_POST_EPI

If @WINDOW = 'RDS' or @WINDOW = 'RDS_POST_EPI' THEN

	CtrlName = @WINDOW:'.MET_TEST'
	MetList = Get_Property(CtrlName,'LIST')
	
	MLCnt = COUNT(MetList,@FM) + (MetList NE '')
	FOR Line = 1 TO MLCnt
		IF MetList<Line,COL$MET_TEST> NE '' THEN
			BEGIN CASE
				CASE MetList<Line,COL$MET_RESULT> = '' 
					Color = YELLOW$
					*EnableUnloadButton	= 0
				CASE MetList<Line,COL$MET_RESULT> < MetList<Line,COL$MET_MIN> OR MetList<Line,COL$MET_RESULT> > MetList<Line,COL$MET_MAX>
					Color = RED$
					*EnableUnloadButton	= 0
				CASE 1
					Color = GREEN$
			END CASE
	
		END	ELSE
			Color = GREEN$
		END;* End of check for Met Test on the current line

		stat = Send_Message(CtrlName,'COLOR_BY_POS',0,Line,Color)
	NEXT Line
	
	IF @WINDOW = 'RDS_POST_EPI' AND (Color = RED$ OR Color = YELLOW$) Then
		WOStep = Get_Property(@WINDOW:'.WO_NO','DEFPROP')
		QAResults = obj_WO_Mat_QA('QAResults',WONo:@RM:WOStep:@RM:CassNo)
		If QAResults NE '' THEN
			EnableQASignButton	= 0
			IF QASignReason = '' THEN QASignReason = QAResults
		END
	END
	
END	

****************************************************************************************************************************************
// RDS_UNLOAD

If @WINDOW EQ 'RDS_UNLOAD' then
    
*    If @USER4 EQ 'FRANCOIS_R' then
        
        CtrlName = @WINDOW:'.EDT_QA_MET'
        Set_Property(@Window : '.MET_TEST', 'VISIBLE', False$)
        Set_Property(CtrlName, 'VISIBLE', True$)
        MetList = Get_Property(CtrlName,'LIST')
        
        MLCnt = COUNT(MetList,@FM) + (MetList NE '')
        FOR Line = 1 TO MLCnt
            IF MetList<Line,COL$UL_MET_TEST> NE '' THEN
                MetResult   = MetList<Line,COL$UL_MET_RESULT>
                MetMin      = MetList<Line,COL$UL_MET_MIN>
                MetMax      = MetList<Line,COL$UL_MET_MAX>
                PhaseMin    = MetList<Line,COL$UL_MET_PHASE_MIN>
                PhaseResult = MetList<Line,COL$UL_MET_PHASE_RESULT>
                ScanRecipe  = MetList<Line,COL$UL_MET_RECIPE>
                PSN         = Get_Property(@Window : '.PSN', 'TEXT')
                PRSStageKey = PSN:'*UNLOAD'
                MetTest     = MetList<Line,COL$UL_MET_TEST>
                PRSStageRec = Database_Services('ReadDataRow', 'PRS_STAGE', PRSStageKey)
                SpecTests   = PRSStageRec<PRS_STAGE_MET_TEST$>
                SpecRecipe  = ''
                Locate MetTest in SpecTests using @VM setting vPos then
                    SpecRecipe = PRSStageRec<PRS_STAGE_MET_RECIPE$, vPos>
                end
                
                
                BEGIN CASE
                    CASE MetList<Line,COL$UL_MET_RESULT> = '' 
                        Color = YELLOW$
                        *EnableUnloadButton	= 0
                    CASE (MetResult LT MetMin) OR (MetResult GT MetMax) OR (PhaseResult LT PhaseMin) OR (ScanRecipe NE SpecRecipe)
                        Color = RED$:@FM:'':@FM:BRED$:@FM:''
                        *EnableUnloadButton	= 0
                    CASE 1
                        Color = GREEN$
                END CASE
        
            END	ELSE
                Color = GREEN$
            END;* End of check for Met Test on the current line

            stat = Send_Message(CtrlName,'COLOR_BY_POS',0,Line,Color)
        NEXT Line
        
        Set_Property(@WINDOW:'.BUTTON_11','ENABLED',EnableUnloadButton)
        
        IF MemberOf(@USER4, 'OI_ADMIN') THEN
            Set_Property(@WINDOW:'.CLEAR_EPI_UNLOAD','VISIBLE',1)
        END ELSE
            Set_Property(@WINDOW:'.CLEAR_EPI_UNLOAD','VISIBLE',0)
        END
    
    
*    end else
*        
*        CtrlName = @WINDOW:'.MET_TEST'
*        MetList = Get_Property(CtrlName,'LIST')
*        
*        MLCnt = COUNT(MetList,@FM) + (MetList NE '')
*        FOR Line = 1 TO MLCnt
*            IF MetList<Line,COL$MET_TEST> NE '' THEN
*                BEGIN CASE
*                    CASE MetList<Line,COL$MET_RESULT> = '' 
*                        Color = YELLOW$
*                        *EnableUnloadButton	= 0
*                    CASE MetList<Line,COL$MET_RESULT> < MetList<Line,COL$MET_MIN> OR MetList<Line,COL$MET_RESULT> > MetList<Line,COL$MET_MAX>
*                        Color = RED$
*                        *EnableUnloadButton	= 0
*                    CASE 1
*                        Color = GREEN$
*                END CASE
*        
*            END	ELSE
*                Color = GREEN$
*            END;* End of check for Met Test on the current line
* 
*            stat = Send_Message(CtrlName,'COLOR_BY_POS',0,Line,Color)
*        NEXT Line
*        
*        Set_Property(@WINDOW:'.BUTTON_11','ENABLED',EnableUnloadButton)
*        
*        IF MemberOf(@USER4, 'OI_ADMIN') THEN
*            Set_Property(@WINDOW:'.CLEAR_EPI_UNLOAD','VISIBLE',1)
*        END ELSE
*            Set_Property(@WINDOW:'.CLEAR_EPI_UNLOAD','VISIBLE',0)
*        END
* 	end	
end
* End of check for Unload OR Post_Epi windows

****************************************************************************************************************************************


IF @WINDOW = 'RDS_POST_EPI' THEN

    If CassSchedShip NE WafersOut then
        BackColor = RED$
    end else
        BackColor = GREEN$
    end
        
    Set_Property(@Window:'.CASS_SHIP_QTY','BACKCOLOR',BackColor)
    Set_Property(@Window:'.WAFERS_OUT','BACKCOLOR',BackColor)

	IF MemberOf(@USER4, 'OI_SUPERUSER') THEN
		Set_Property(@WINDOW:'.SAP_SIGN','VISIBLE',1)
		Set_Property(@WINDOW:'.SAP_REJECT','VISIBLE',1)
	END ELSE
		Set_Property(@WINDOW:'.SAP_SIGN','VISIBLE',0)
		Set_Property(@WINDOW:'.SAP_REJECT','VISIBLE',0)
	END
	
	ROTRAction      = Get_Property(@WINDOW:'.ROTR_ACTION','TEXT')  
	BEGIN CASE
		CASE ROTRAction[1,1] = 'P'
			 BackColor = GREEN$
		CASE ROTRAction[1,1] = 'F'
			 BackColor = RED$
		CASE ROTRAction[1,1] = 'W'
			 BackColor = YELLOW$
    	CASE ROTRAction[1,1] = 'A'
			 BackColor = ORANGE$
		CASE 1
			BackColor = Get_Property(@WINDOW,'BACKCOLOR')
	END CASE
	Set_Property(@WINDOW:'.ROTR_ACTION','BACKCOLOR',BackColor)

    **************************************
    * Refreshing Flat Finder Information *
    **************************************
    EpiPartNo               = Get_Property(@Window : '.EPI_PART_NO', 'TEXT')
    WaferSize               = Xlate('EPI_PART', EpiPartNo, 'SUB_WAFER_SIZE', 'X')
    WaferSizeInch           = Field(WaferSize, ' ', 3, 1)
    RDSNo                   = Get_Property(@Window : '.RDS_NO','DEFPROP')
    CustNo                  = Xlate('RDS', RDSNo, 'CUST_NO', 'X')
    // Get Bench Mark Values
    CompanyRow              = Xlate('COMPANY', CustNo, '', 'X')
    WaferFlatSizeInches     = CompanyRow<COMPANY_WAFER_FLAT_WAFER_SIZE_INCH$>
    WaferFlatLengthMins     = Oconv(CompanyRow<COMPANY_WAFER_FLAT_LENGTH_MIN$>, 'MD1')
    WaferFlatLengthMaxes    = Oconv(CompanyRow<COMPANY_WAFER_FLAT_LENGTH_MAX$>, 'MD1')
    Locate 6 in WaferFlatSizeInches using @VM setting vPos then
        WaferFlatLengthMin  = WaferFlatLengthMins<0, vPos>
        WaferFlatLengthMax  = WaferFlatLengthMaxes<0, vPos>
    end else
        WaferFlatLengthMin  = ''
        WaferFlatLengthMax  = ''
    end
    WafersOut = Get_Property(@WINDOW:'.WAFERS_OUT','TEXT')        

    // Get FlatFinder Read Value
    FlatFinderWafersQty     = Get_Property(@WINDOW:'.FLAT_FINDER_WAFER_QTY','DEFPROP')
    FlatFinderWaferLength   = Get_Property(@WINDOW:'.FLAT_FINDER_FLAT_LENGTH','DEFPROP')
    
    If (WaferSizeInch EQ 6) then
        ***************************************
        * FlatFinder - Wafers Quatity Section *
        ***************************************
        If (FlatFinderWafersQty NE '') then
            If (FlatFinderWafersQty = WafersOut) then
                QtyBackColor        = GREEN$
            end else
                QtyBackColor        = RED$
*                EnableQASignButton  = 0
            end
        end else
            QtyBackColor    = ORANGE$
*            EnableQASignButton  = 0
        end
        ************************************
        * FlatFinder - Flat Length Section *
        ************************************
        If (WaferFlatLengthMin NE '') AND (WaferFlatLengthMax NE '') then
            If (FlatFinderWaferLength NE '') then
                If (FlatFinderWaferLength GE WaferFlatLengthMin) AND (FlatFinderWaferLength LE WaferFlatLengthMax) then
                    LengthBackColor     = GREEN$
                end else
                    LengthBackColor     = RED$
*                    EnableQASignButton  = 0
                end
            end else
                LengthBackColor     = ORANGE$
*                EnableQASignButton  = 0
            end
        end else
            LengthBackColor = GREY$
        end
    end else
        QtyBackColor    = GREY$
        LengthBackColor = GREY$
    end
    Set_Property(@WINDOW:'.FLAT_FINDER_WAFER_QTY','BACKCOLOR', QtyBackColor)
    Set_Property(@WINDOW:'.FLAT_FINDER_FLAT_LENGTH','BACKCOLOR', LengthBackColor)

end

* * * * * Layer Set edit table control in Load and Post Epi windows

IF @WINDOW = 'RDS' OR @WINDOW = 'RDS_POST_EPI' THEN
	
	IF Get_Property(@WINDOW:'.INV_FAB_COMP','CHECK') = 1 THEN
		Set_Property(@WINDOW:'.INV_FAB_HRS','BACKCOLOR',GREEN$)
	END ELSE
		Set_Property(@WINDOW:'.INV_FAB_HRS','BACKCOLOR',YELLOW$)
	END
	
	CtrlID = @WINDOW:'.RDS_LS_ID'
	
	LayerList = Get_Property(CtrlID,'LIST')

	FOR I = 1 TO COUNT(LayerList,@FM) + (LayerList NE '')
		
		* Layer Set Parameters
	
		IF ICONV(LayerList<I,COL$PARMS_OUT>,'B') = 1 THEN
			ParmColor = RED$
		END ELSE
			IF ICONV(LayerList<I,COL$PARAMS>,'B') = 0 THEN
				ParmColor = YELLOW$
				EnableQASignButton	= 0
				IF QASignReason = '' THEN QASignReason ='Recipe Parameters incomplete'
				
			END ELSE
				ParmColor = GREEN$
			END
		END
		
		FOR Col = COL$LSID TO COL$PARMS_OUT
			stat = Send_Message(CtrlID,'COLOR_BY_POS',Col,I,ParmColor)
		NEXT Col
		
		* ASM Metrology
		
		
		IF LayerList<I,COL$MET_NO> NE '' THEN
			MetNo 	= LayerList<I,COL$MET_NO>
			MetRec 	= XLATE('RDS_TEST',MetNo,'','X')
			
			TWSigned 	= obj_RDS_Test('TWSignedOff',MetNo:@RM:MetRec)
			TestComp 	= obj_RDS_Test('TestComplete',MetNo:@RM:MetRec)
			OutOfSpec	= obj_RDS_Test('OutOfSpec',MetNo:@RM:MetRec)
			
			IF NOT(obj_RDS_Test('TWSignedOff',MetNo:@RM:MetRec)) THEN
				MetColor = ORANGE$
				EnableLoadButton = 0
			END
				
			IF NOT(obj_RDS_Test('TestComplete',MetNo:@RM:MetRec)) THEN
				MetColor = ORANGE$
				EnableQASignButton	= 0
				IF QASignReason = '' THEN QASignReason = 'Metrology not signed off for Met No: ':MetNo
			END ELSE
			
				IF obj_RDS_Test('OutOfSpec',MetNo:@RM:MetRec) = 1 THEN
					MetColor = RED$
					EnableQASignButton	= 0
					IF QASignReason = '' THEN QASignReason = 'Metrology ':MetNo:' is out of spec'
					
				END ELSE
					IF LayerList<I,COL$THICK_AVG> = '' AND LayerList<I,COL$RRHO_AVG> = '' AND LayerList<I,COL$MET_NO> NE '' THEN
						MetColor = YELLOW$
						EnableQASignButton	= 0
						IF QASignReason = '' THEN QASignReason = 'Metrology incomplete'
					END ELSE
						MetColor = GREEN$
					END
				END
			END
		END
		
		FOR Col = COL$MET_NO TO COL$RRHO_AVG
			stat = Send_Message(CtrlID,'COLOR_BY_POS',Col,I,MetColor)
		NEXT Col
		
		* Zone 1 EpiPRO Metrology
		
		IF LayerList<I,COL$MET_NO_Z1> NE '' THEN
			MetNo 	= LayerList<I,COL$MET_NO_Z1>
			MetRec 	= XLATE('RDS_TEST',MetNo,'','X')
			
			TWSigned 	= obj_RDS_Test('TWSignedOff',MetNo:@RM:MetRec)
			TestComp 	= obj_RDS_Test('TestComplete',MetNo:@RM:MetRec)
			OutOfSpec	= obj_RDS_Test('OutOfSpec',MetNo:@RM:MetRec)
			
			IF NOT(obj_RDS_Test('TWSignedOff',MetNo:@RM:MetRec)) THEN
				MetColorZ1 = ORANGE$
				EnableLoadButton = 0
			END
				
			IF NOT(obj_RDS_Test('TestComplete',MetNo:@RM:MetRec)) THEN
				MetColorZ1	 = ORANGE$
				EnableQASignButton	= 0
				IF QASignReason = '' THEN QASignReason ='Zone 1 Metrology is Incomplete'
			END ELSE
			
				IF obj_RDS_Test('OutOfSpec',MetNo:@RM:MetRec) = 1 THEN
					MetColorZ1 = RED$
					EnableQASignButton = 0
					IF QASignReason = '' THEN QASignReason ='Zone 1 Metrology is Out of Spec'
					
				END ELSE
					IF LayerList<I,COL$THICK_AVG_Z1> = '' AND LayerList<I,COL$RRHO_AVG_Z1> = '' AND LayerList<I,COL$MET_NO_Z1> NE '' THEN
						MetColorZ1 = YELLOW$
						EnableQASignButton	= 0
						IF QASignReason = '' THEN QASignReason = 'Zone 1 Metrology is Incomplete'
					END ELSE
						MetColorZ1 = PRE_BLUE$
					END
				END
			END
		END
		
		FOR Col = COL$MET_NO_Z1 TO COL$RRHO_AVG_Z1
			stat = Send_Message(CtrlID,'COLOR_BY_POS',Col,I,MetColorZ1)
		NEXT Col
		
		* Zone 2 EpiPRO Metrology
		
		IF LayerList<I,COL$MET_NO_Z2> NE '' THEN
			MetNo 	= LayerList<I,COL$MET_NO_Z2>
			MetRec 	= XLATE('RDS_TEST',MetNo,'','X')
			
			TWSigned 	= obj_RDS_Test('TWSignedOff',MetNo:@RM:MetRec)
			TestComp 	= obj_RDS_Test('TestComplete',MetNo:@RM:MetRec)
			OutOfSpec	= obj_RDS_Test('OutOfSpec',MetNo:@RM:MetRec)
			
			IF NOT(obj_RDS_Test('TWSignedOff',MetNo:@RM:MetRec)) THEN
				MetColorZ2 = ORANGE$
				EnableLoadButton = 0
			END
				
			IF NOT(obj_RDS_Test('TestComplete',MetNo:@RM:MetRec)) THEN
				MetColorZ2 = ORANGE$
				EnableQASignButton = 0
				IF QASignReason = '' THEN QASignReason = 'Zone 2 Metrology is Incomplete'
			END ELSE
			
				IF obj_RDS_Test('OutOfSpec',MetNo:@RM:MetRec) = 1 THEN
					MetColorZ2 = RED$
					EnableQASignButton = 0
					IF QASignReason = '' THEN QASignReason = 'Zone 2 Metrology is Out of Spec'
				END ELSE
					IF LayerList<I,COL$THICK_AVG_Z2> = '' AND LayerList<I,COL$RRHO_AVG_Z2> = '' AND LayerList<I,COL$MET_NO_Z2> NE '' THEN
						MetColorZ2 = YELLOW$
						EnableQASignButton	= 0
						IF QASignReason = '' THEN QASignReason = 'Zone 2 Metrology is Incomplete'
					END ELSE
						MetColorZ2 = INP_BLUE$
					END
				END
			END
		END
		
		FOR Col = COL$MET_NO_Z2 TO COL$RRHO_AVG_Z2
			stat = Send_Message(CtrlID,'COLOR_BY_POS',Col,I,MetColorZ2)
		NEXT Col
		
	NEXT I
	
	LoadLockVal = Get_Property(@WINDOW:'.LOAD_LOCK_SIDE_HIDDEN','TEXT')
	IF LoadLockVal = '' THEN
		CurrSaveWarn = Get_Property(@WINDOW,'SAVEWARN')
		Set_Property(@WINDOW:'.LOAD_LOCK_SIDE','DEFPROP','')
		IF NOT(CurrSaveWarn) THEN
			Set_Property(@WINDOW,'SAVEWARN',0)
		END
	END
	
	Reactor = Get_Property(@WINDOW:'.REACTOR','DEFPROP')				;* Changed to PickPlaceFlag on 12/6/2011 JCH
	
	PickPlaceFlag = XLATE('REACTOR',Reactor,REACTOR_PICK_PLACE$,'X')
	
	IF PickPlaceFlag THEN
		Set_Property(@WINDOW:'.ASM_LOAD_LOCK','ENABLED',1)
	END ELSE
		Set_Property(@WINDOW:'.ASM_LOAD_LOCK','ENABLED',0)
	END
	
	
	WafersIn = Get_Property(@WINDOW:'.WAFERS_IN','DEFPROP')
	IF WafersIn = '' THEN
		Set_Property(@WINDOW:'.BUTTON_11','ENABLED',0)			;* Load button disabled 
	END ELSE
		IF EnableLoadButton = 1 OR MemberOf(@USER4, 'OI_ADMIN') THEN
			Set_Property(@WINDOW:'.BUTTON_11','ENABLED',1)		;* Load button Added flag on 11/14/2007 JCH
		END
	END
END

* Clean Inspection table
	
CtrlName = ''

IF @WINDOW = 'RDS_PRE_EPI' THEN CtrlName	= @WINDOW:'.PRE_CI_ACTION'
IF @WINDOW = 'RDS' THEN CtrlName			= @WINDOW:'.FWI_CI_ACTION'
IF @WINDOW = 'RDS_UNLOAD' THEN CtrlName		= @WINDOW:'.LWI_CI_ACTION'
IF @WINDOW = 'RDS_POST_EPI' THEN CtrlName	= @WINDOW:'.POST_CI_ACTION'

IF CtrlName NE '' THEN
	CIList		= Get_Property(CtrlName,'LIST')
	CICnt		= COUNT(CIList,@FM) + (CIList NE '')
	
	FOR Line = 1 TO CICnt
		IF CIList<Line,COL$ACTION> NE '' THEN
		
			BEGIN CASE
			
				CASE CIList<Line,COL$TOOL> = '' 
					Color = YELLOW$
					EnableUnloadButton	= 0											;* 1/9/2013 JCH
					EnableQASignButton	= 0
					IF QASignReason = '' THEN QASignReason = 'Clean Inspection Steps Required'
				
				CASE CIList<Line,COL$TOOL> NE '' AND CIList<Line,COL$SIG> = '' 
					Color = RED$
					EnableUnloadButton	= 0
					EnableQASignButton	= 0
					IF QASignReason = '' THEN QASignReason = 'Clean Inspection Steps not Signed'
					
				CASE 1
					Color = GREEN$
			END CASE
	
		END	ELSE
			Color = GREEN$
		END;* End of check for Clean Insp complete on the current line
		
		stat = Send_Message(CtrlName,'COLOR_BY_POS',0,Line,Color)
		IF QASignReason = '' THEN
			Set_Property(@WINDOW:'.STATUS_LINE','TEXT','')
		END ELSE
			Set_Property(@WINDOW:'.STATUS_LINE','TEXT',QASignReason)
		END
	NEXT Line
END	;* End of check for CtrlName


IF @WINDOW = 'RDS_POST_EPI' THEN

	/*
	* * * * Existing Checks for ADE		;* Dead on 8 Jan 2013 JCH

	Ctrls = @WINDOW:'.ADE_READ':@RM:@WINDOW:'.THICK_MIN':@RM:@WINDOW:'.THICK_MAX'
	Props = 'DEFPROP':@RM:'DEFPROP':@RM:'DEFPROP'
	Vals = Get_Property(Ctrls,Props)
	
	ADERead		= Vals[1,@RM]
	ThickMin	= Vals[COL2()+1,@RM]
	ThickMax 	= Vals[COL2()+1,@RM]
	
	IF ADERead = '' THEN
		Set_Property(@WINDOW:'.ADE_READ','BACKCOLOR',WHITE$)
	END ELSE
		IF ADERead < ThickMin OR ADERead > ThickMax THEN
			Set_Property(@WINDOW:'.ADE_READ','BACKCOLOR',RED$)
		END ELSE
			Set_Property(@WINDOW:'.ADE_READ','BACKCOLOR',GREEN$)
		END
	END
	
	* * * * * End of existing ADE Check
	*/
	
	NCRList = Get_Property(@WINDOW:'.NCR_KEYS','LIST')

	FOR Line = 1 TO COUNT(NCRList,@FM) + (NCRList NE '')
		Status = NCRList<Line,2>
		
		IF Status NE '' AND Status NE 'Closed' THEN
			EnableQASignButton = 0
			QASignReason 	= 'Open NCR'
		END
	NEXT Line
	
	IF UseMUWafers THEN
		IF (WafersOut NE '' AND WafersScheduled NE '') THEN
		    // A full box is now defined by have equal to or more wafers required. This allows certain customer's parts
		    // to have a box with less that 25 wafers be allowed to ship. - 08/04/2017
*			IF WafersOut NE FullBoxQty  AND NOT(MakeupBox) THEN
            IF WafersOut LT MinCassShipQty AND NOT(MakeupBox) THEN
				EnableQASignButton = 0
				QASignReason	= 'Wafer Out is not equal to Specified Full Box Quantity'
			END
		END
	END
	
	** Added 11/1/2013 JCH... another AFUD
	
	RotrAction = Get_Property(@WINDOW:'.ROTR_ACTION','TEXT')
	
	IF RotrAction[1,1] = 'F' Then
		EnableQASignButton = 0
		QASignReason	= 'Failed ROTR test'
	
		/*
		PostCIArray = Get_Property(@WINDOW:'.POST_CI_ACTION','ARRAY')
		
		LOCATE 'SurfScan' IN PostCIArray<COL$ACTION> USING @VM SETTING Pos THEN
			IF PostCIArray<COL$SIG,Pos> = '' THEN
				EnableQASignButton = 0
				QASignReason	= 'SurfScan not signed after ROTR test failed'
			END
		END ELSE
			EnableQASignButton = 0
			QASignReason	= 'SurfScan not performed after ROTR test failed'
		End
		*/
	END
	
	
	*IF @USER4 = 'DAVID_KL' THEN EnableQASignButton = 1
	If MemberOf(@USER4, 'OI_ADMIN') then
	    EnableQASignButton = 1
    end
	
	Set_Property(@WINDOW:'.SIGN_BUTTON','ENABLED',EnableQASignButton)
	
	IF QASignReason = '' THEN
		Set_Property(@WINDOW:'.STATUS_LINE','TEXT','')
		Set_Property(@WINDOW:'.STATUS_LINE','BACKCOLOR',LTGREY$)
	
	END ELSE
		Set_Property(@WINDOW:'.STATUS_LINE','TEXT',QASignReason)
		Set_Property(@WINDOW:'.STATUS_LINE','BACKCOLOR',YELLOW$)
	END
	
	
	
END

IF @WINDOW = 'RDS' OR @WINDOW = 'RDS_UNLOAD' THEN
	Reactor = Get_Property(@WINDOW:'.REACTOR','DEFPROP')
	ReactorType = XLATE('REACTOR',Reactor,1,'X')
	IF ReactorType = 'EPP' THEN
		Set_Property(@WINDOW:'.LOAD_EPI_PRO','VISIBLE',1)
		Set_Property(@WINDOW:'.UNLOAD_EPI_PRO','VISIBLE',1)
		Set_Property(@WINDOW:'.POCKET','VISIBLE',1)
		Set_Property(@WINDOW:'.MOVE_MET','VISIBLE',1)
		Set_Property(@WINDOW:'.ADD_ZONE','VISIBLE',1)
	END ELSE
		Set_Property(@WINDOW:'.LOAD_EPI_PRO','VISIBLE',0)
		Set_Property(@WINDOW:'.UNLOAD_EPI_PRO','VISIBLE',0)
		Set_Property(@WINDOW:'.POCKET','VISIBLE',0)
		Set_Property(@WINDOW:'.MOVE_MET','VISIBLE',0)
		Set_Property(@WINDOW:'.ADD_ZONE','VISIBLE',0)
	END
END
RETURN


* * * * * * *
GotFocus:
* * * * * * *


RETURN


* * * * * * *
MUWafers:
* * * * * * *

RDSNo = Get_Property(@WINDOW,'ID')
IF RDSNo = '' THEN RETURN

IF Get_Property(@WINDOW,'SAVEWARN') THEN
	Send_Event(@WINDOW,'WRITE')
END

obj_AppWindow('ViewRelated','RDS_MAKEUP':@RM:RDSNo)

RETURN


* * * * * * * 
ProdWfrLF:
* * * * * * *
RETURN


* * * * * * *
Update:
* * * * * * *

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

IF RDSNo NE '' THEN
	Send_Event(@WINDOW,'WRITE')
	Set_Property(@WINDOW:'.RDS_NO','TEXT',RDSNo)
	Send_Event(@WINDOW,'READ')
END

RETURN


* * * * * * *
WafersInLF:
* * * * * * *

WafersIn	= Get_Property(@WINDOW:'.WAFERS_IN','TEXT')
RDSNo		= Get_Property(@WINDOW,'ID')

IF WafersIn = '' THEN RETURN

ScheduledWafers = XLATE('RDS',RDSNo,'WAFERS_SCHEDULED','X')

IF WafersIn NE ScheduledWafers THEN
		
	UserInput = Msg(@window, '','WAFERS_IN_VERIFY')
	IF UserInput = CHAR(27) THEN
	   Set_Property(@WINDOW:'.WAFERS_IN','TEXT','')
	   Set_Property(@WINDOW:'.WAFERS_IN','FOCUS',1)
	END
END

GOSUB Refresh

RETURN


* * * * * * *
FirstRead:
* * * * * * *
* Hooked from RDS (first wafer) screen



* * * * * * *
FirstRefresh:
* * * * * * *

OverGrowRequired = Get_Property(@WINDOW:'.OVERGROW_REQ','CHECK')

IF OverGrowRequired THEN
	Set_Property(@WINDOW:'.THICK_OVR_GROWTH_AVG','VISIBLE',1)
	Set_Property(@WINDOW:'.THICK_OVER_LABEL','VISIBLE',1)
END ELSE
	Set_Property(@WINDOW:'.THICK_OVR_GROWTH_AVG','VISIBLE',0)
	Set_Property(@WINDOW:'.THICK_OVER_LABEL','VISIBLE',0)
END

GOSUB Refresh

RETURN


* * * * * * *
SupVerSigLF:
* * * * * * *

RDSNo		= Get_Property(@WINDOW,'ID')
SupVerSig	= Get_Property(@WINDOW:'.POST_EPI_SUP_SIG','TEXT')
PostEpiSig	= Get_Property(@WINDOW:'.POST_EPI_SIG','TEXT')

IF SupVerSig = PostEpiSig THEN
	ErrorMesg  = 'User ':QUOTE(PostEpiSig):' has signed this RDS as Operator Out.':CRLF$:CRLF$
	ErrorMesg := 'Another qualified user must sign verification'
	Set_Property(@WINDOW:'.POST_EPI_SUP_SIG','TEXT','')
END

RETURN


* * * * * * *
NewNCR:
* * * * * * *

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

WOStepKey = XLATE('RDS',RDSNo,RDS_WO_STEP_KEY$,'X')

WONo = WOStepKey[1,'*']
WOStep = WOStepKey[COL2()+1,'*']

CassNo = XLATE('RDS',RDSNo,'RUN_ORDER_NUM','X')


IF 1 = 1 THEN	;* This was a test for non-test users

	************* This is the production code ********************
	
	NewNCRNo = obj_NCR('Create',WONo:@RM:WOStep:@RM:CassNo:@RM:RDSNo:@RM:Reactor)
	IF Get_Status(errCode) THEN
		ErrMsg(errCode)
		RETURN
	END

	CtrlEntID = @WINDOW:'.NCR_KEYS'

	NCRNos = Get_Property(CtrlEntID,'ARRAY')<1>

	SWAP @VM:@VM WITH '' IN NCRNos
	IF NCRNos[-1,1] = @VM THEN NCRNos[-1,1] = ''

	LastNCRNo = COUNT(NCRNos,@VM) + (NCRNos NE '')

	Send_Event(@WINDOW,'WRITE')

	DetWindow	= 'NCR'
	DetKeys		= NewNCRNo
	DefaultRec	= ''
	RetKey		= RDSNo
	RetWin		= @WINDOW
	RetPage		= 1
	RetCtrl		= CtrlEntID
	RetPos		= 1:@FM:LastNCRNo + 1

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

END ELSE
	
	************* This is the test code ********************

	CtrlEntID = @WINDOW:'.NCR_KEYS'

	NCRNos = Get_Property(CtrlEntID,'ARRAY')<1>

	SWAP @VM:@VM WITH '' IN NCRNos
	IF NCRNos[-1,1] = @VM THEN NCRNos[-1,1] = ''

	LastNCRNo = COUNT(NCRNos,@VM) + (NCRNos NE '')

	Send_Event(@WINDOW,'WRITE')

	CreateParms  = WONo:@FM
	CreateParms := CassNo:@FM
	CreateParms := RDSNo:@FM
	CreateParms := Reactor:@FM
	CreateParms := WOStep:@FM
	CreateParms := '1':@FM					;* Return Page
	CreateParms := '.NCR_KEYS':@FM			;* Return Ctrl
	CreateParms := '1,1'


	thisFormWindowUp = Get_Property('WO_MAT_WFR','VISIBLE')	;* Returns 0 = hidden, 1 = visible, 2 = minimized, 3 = maximized 

	IF thisFormWindowUp = ''	THEN
		Start_Window('WO_MAT_WFR',@WINDOW,CreateParms)
	END ELSE

		IF thisFormWindowUp = 2		THEN Set_Property('WO_MAT_WFR','VISIBLE',9)	;* Restore the window if minimized

		IF Get_Property('WO_MAT_WFR','SAVEWARN') THEN
			Set_Property('WO_MAT_WFR','@SKIP_CARD_RETURN',1)	;* This stops the Return behavior
			Send_Event('WO_MAT_WFR','CLEAR')					;* Clear anything existing (prompts for save first)
		END
		
		* Load Key Controls with Key Parts

		Ctrls  = 'WO_MAT_WFR':@RM				; Props  = '@RETURN_KEY':@RM		; Vals  = RDSNo:@RM
		Ctrls := 'WO_MAT_WFR':@RM				; Props := '@RETURN_PAGE':@RM		; Vals := '':@RM
		Ctrls := 'WO_MAT_WFR':@RM				; Props := '@RETURN_CONTROL':@RM	; Vals := 'RDS_UNLOAD.NCR_KEYS':@RM
		Ctrls := 'WO_MAT_WFR':@RM				; Props := '@RETURN_POS':@RM		; Vals := 1:@FM:1:@RM
		
		Ctrls := 'WO_MAT_WFR.WO_NO':@RM			; Props := 'DEFPROP':@RM			; Vals := WONo:@RM
		Ctrls := 'WO_MAT_WFR.CASS_NO':@RM		; Props := 'DEFPROP':@RM			; Vals := CassNo:@RM
		Ctrls := 'WO_MAT_WFR.RDS_NO':@RM		; Props := 'DEFPROP':@RM			; Vals := RDSNo:@RM
		Ctrls := 'WO_MAT_WFR.REACTOR':@RM		; Props := 'DEFPROP':@RM			; Vals := Reactor:@RM
		Ctrls := 'WO_MAT_WFR.WO_STEP_NO'		; Props := 'DEFPROP'				; Vals := WOStep
			
		Set_Property(Ctrls,Props,Vals)
		
		Send_Event('WO_MAT_WFR.CASS_NO','LOSTFOCUS')
		
	END

END	;* End of section with new test code 

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

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


* * * * * * *
PrintLabels:
* * * * * * *

RDSNo = Get_Property(@WINDOW,'ID')

IF RDSNo = '' THEN RETURN

IF Security_Check( 'RDS', Print$ ) ELSE
	Security_Err_Msg( 'RDS', Print$ )
	RETURN
END

Send_Event(@WINDOW,'WRITE')

WOStepKey	= XLATE('RDS',RDSNo,RDS_WO_STEP_KEY$,'X')
WONo		= WOStepKey[1,'*']
WOStep		= WOStepKey[-1,'*']
WOSteps		= XLATE('WO_LOG',WONo,WO_LOG_WO_STEP_KEY$,'X')

IF INDEX(WOSteps,@VM,1) THEN
	MultiStepFlag = 1
END ELSE
	MultiStepFlag = 0
END

IF WOStep > 1 THEN
	RDSNos = obj_WO_Step('AdjStepRDSQtys', WOStep:@RM:WOSteps)		;* Returns RDSNos for nth step that have completed step n-1
	IF Get_Status(errCode) THEN ErrMsg(errCode)
	IF RDSNos = '' THEN
		ErrMsg('No cassettes have completed Step ':WOStep - 1)
		GOTO SkipIt
	END
END ELSE
	RetVal = Msg(@WINDOW,'','SELECT_CASS_LABEL')
	IF RetVal = 1 THEN
		RDSNos = RDSNo
	END ELSE
		RDSNos = XLATE('WO_STEP',WOSteps<1,1>,WO_STEP_RDS_KEY$,'X')
	END
END

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

IF INDEX(RDSNos,@VM,1) THEN
	TypeOver = ''
	TypeOver<PDISPLAY$> = RDSNos
	TypeOver<PFIELD$>	= 2
	TypeOver<PTYPE$>	= 'K'
	
	RDSKeys = Popup(@WINDOW,TypeOver,'WO_LOG_RTS')
	
END ELSE
	RDSKeys = RDSNos
END

IF RDSKeys = '' THEN RETURN

CONVERT @VM TO @FM IN RDSKeys

Def = ""
Def<MTEXT$> = "Printing Cassette Labels..."
Def<MTYPE$> = "U"

MsgUp = Msg(@window, Def)

Print_Cass_Labels(RDSKeys,MultiStepFlag)				;* Updated labels with Akrion Bar Codes

Msg(@window, MsgUp)


* * * *
SkipIt:
* * * *

Set_Property(@WINDOW:'.RDS_NO','TEXT',RDSNo)
Send_Event(@WINDOW,'READ')

RETURN


* * * * * * *
ViewAudit:
* * * * * * *

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

IF RDSNo = '' THEN RETURN

*AuditData	= obj_RDS_Audit('Display',RDSNo:@RM:@WINDOW)	;* Returns all audit columns for this window
AuditData	= obj_RDS_Audit('Display',RDSNo:@RM:'')	;* Returns all audit columns 

DispText 	= AuditData[1,@RM]
UserNames	= AuditData[COL2()+1,@RM]
LastDTMS	= AuditData[COL2()+1,@RM]
Windows		= AuditData[COL2()+1,@RM]

PopupDisplay = ''

FOR I = 1 TO COUNT(DispText,@FM) + (DispText NE '')
	PopupDisplay<1,I> = DispText<I>:@TM:OCONV(UserNames<I>,'[XLATE_CONV,LSL_USERS*FIRST_LAST]' ):@TM:LastDTMs<I>:@TM:Windows<I>
NEXT I

OverRide = ''
OverRide<PDISPLAY$> = PopupDisplay

PopUp(@WINDOW, OverRide, 'RDS_MOD_HIST_VIEW' )

RETURN


* * * * * * *
LSIdDC:
* * * * * * *

CtrlEntID	= @WINDOW:'.RDS_LS_ID'
RDSNo		= Get_Property(@WINDOW,'ID')
ReactNo		= Get_Property(@WINDOW:'.REACTOR','DEFPROP')

IF Get_Property(@WINDOW,'SAVEWARN') THEN
	Set_Property(@WINDOW,'@SKIP_SAVEWARN',0)
END ELSE
	Set_Property(@WINDOW,'@SKIP_SAVEWARN',1)
END

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


IF CurrCol LT COL$MET_NO THEN
	LSId = Get_Property(CtrlEntID,'CELLPOS',COL$LSID:@FM:CurrRow)

	IF RDSNo NE '' AND LSId NE '' THEN
	
		/*IF ReactNo = '' THEN
			ErrMsg('':@VM:'Process Error':@SVM:'Reactor No. is required prior to recording test results.')
			RETURN 0
		END
		*/
		
		Send_Event(@WINDOW,'WRITE')

		RdsLSID = RDSNo:'*':LSId

		DetWindow	= 'RDS_LAYER'
		DetKeys		= RdsLSID
		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)
	
	END
END

IF CurrCol = COL$MET_NO OR CurrCol = COL$MET_NO_Z1 OR CurrCol = COL$MET_NO_Z2 THEN
	MetNo = Get_Property(CtrlEntID,'CELLPOS',CurrCol:@FM:CurrRow)
	

	/*IF ReactNo = '' THEN
		ErrMsg('':@VM:'Process Error':@SVM:'Reactor No. is required prior to recording test results.')
		RETURN 0
	END
	*/
	
	IF MetNo NE '' THEN
		
		Send_Event(@WINDOW,'WRITE')
        Send_Event(@WINDOW,'CLEAR') ; // 12/21/2017 - DMB - Although WRITE normally clears the form, QBF mode will prevent the clear so do this explicitly so the lock is removed from the RDS record.

		DetWindow	= 'RDS_TEST'
		DetKeys		= MetNo
		DefaultRec	= ''
		RetKey		= RDSNo
		RetWin		= 'RDS'
		RetPage		= 1
		RetCtrl		= CtrlEntID
		RetPos		= CurrPos
		
		obj_Appwindow('ViewNewDetail',DetWindow:@RM:DetKeys:@RM:DefaultRec:@RM:RetKey:@RM:RetPage:@RM:RetCtrl:@RM:RetPos)
			
	END
END



RETURN


* * * * * * *
LoadEpiPro:
* * * * * * * 

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

IF RDSNo = '' THEN RETURN

OutCassettes = CurrentLoad<COL$OUT_CASS>

CONVERT @VM TO '' IN OutCassettes

IF OutCassettes NE '' THEN
	ErrMsg('Wafers have already been unloaded from the reactor.')
	RETURN
END

/*
IF Security_Check( 'RDS', Print$ ) ELSE
	Security_Err_Msg( 'RDS', Print$ )
	RETURN
END
*/

Reactor = Get_Property(@WINDOW:'.REACTOR','TEXT')

ReactorType = XLATE('REACTOR',Reactor,1,'X')

IF ReactorType NE 'EPP' THEN
	ErrMsg('Reactor ':Reactor:' is not an EpiPro tool.')
	RETURN
END

Send_Event(@WINDOW,'WRITE')


MatlLoadInfo = Create_Dialog('DIALOG_LOAD_EPI_PRO', @WINDOW, 0, RDSNo:@FM:CurrentLoad)


RETURN


* * * * * * *
UnloadEpiPro:
* * * * * * * 
	
RDSNo		= Get_Property(@WINDOW:'.RDS_NO','DEFPROP')
CurrentLoad = Get_Property(@WINDOW:'.POCKET','DEFPROP')

IF RDSNo = '' THEN RETURN

/*
IF Security_Check( 'RDS', Print$ ) ELSE
	Security_Err_Msg( 'RDS', Print$ )
	RETURN
END
*/

Reactor = Get_Property(@WINDOW:'.REACTOR','TEXT')

ReactorType = XLATE('REACTOR',Reactor,1,'X')

IF ReactorType NE 'EPP' THEN
	ErrMsg('Reactor ':Reactor:' is not an EpiPro tool.')
	RETURN
END

ProdLoadCnt = 0
ProdUnloadCnt = 0

FOR I = 1 TO COUNT(CurrentLoad<1>,@VM) + (CurrentLoad<1> NE '')
	
	Usage	= CurrentLoad<COL$USE,I>
	WfrType	= CurrentLoad<COL$CHAR,I>
	OutCass	= CurrentLoad<COL$OUT_CASS,I>

	IF WfrType = 'PROD' AND Usage = '' AND OutCass = '' THEN
		ProdLoadCnt += 1											;* Product wafers to be unloaded
	END
	
	IF OutCass NE '' THEN
		ProdUnloadCnt += 1
	END

NEXT I

IF ProdLoadCnt = 0 AND ProdUnloadCnt = 0 THEN
	ErrMsg('No production wafers loaded in reactor.')		;* Not yet loaded
	RETURN
END
		
Send_Event(@WINDOW,'WRITE')

MatlUnloadInfo = Create_Dialog('DIALOG_UNLOAD_EPI_PRO', @WINDOW, 0, RDSNo:@FM:CurrentLoad)

RETURN


* * * * * * * *
ClearEpiUnload:
* * * * * * * *

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

IF RDSNo = '' THEN RETURN

Reactor = Get_Property(@WINDOW:'.REACTOR','TEXT')

ReactorType = XLATE('REACTOR',Reactor,1,'X')

IF ReactorType NE 'EPP' THEN
	ErrMsg('Reactor ':Reactor:' is not an EpiPro tool.')
	RETURN
END

ProdLoadCnt = 0
ProdUnloadCnt = 0

FOR I = 1 TO COUNT(CurrentLoad<1>,@VM) + (CurrentLoad<1> NE '')
	
	Usage	= CurrentLoad<COL$USE,I>
	WfrType	= CurrentLoad<COL$CHAR,I>
	OutCass	= CurrentLoad<COL$OUT_CASS,I>

	IF WfrType = 'PROD' AND Usage = '' AND OutCass = '' THEN
		ProdLoadCnt += 1											;* Product wafers to be unloaded
	END
	
	IF OutCass NE '' THEN
		ProdUnloadCnt += 1
	END

NEXT I

IF ProdLoadCnt = 0 AND ProdUnloadCnt = 0 THEN
	ErrMsg('No production wafers loaded in reactor.')		;* Not yet loaded
	RETURN
END
		
Send_Event(@WINDOW,'WRITE')


Set_Status(0)
obj_RDS('ClearEpiUnload',RDSNo) ; // Note: This routine does not exist in OBJ_RDS

IF Get_Status(errCode) THEN
	ErrMsg(errCode)
END

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

RETURN



* * * * * * *
AddZoneMet:
* * * * * * *

CtrlEntID = @WINDOW:'.RDS_LS_ID'

RDSNo	= Get_Property(@WINDOW,'ID')
PSNo	= Get_Property(@WINDOW:'.PSN','DEFPROP')
LSArray = Get_Property(CtrlEntID,'DEFPROP')

LSIDs		= LSArray<COL$LSID>
MetNos		= LSArray<COL$MET_NO>
MetNosZ1	= LSArray<COL$MET_NO_Z1>
MetNosZ2	= LSArray<COL$MET_NO_Z2>

MetTest	= MetNos
Z1Test	= MetNosZ1
Z2Test	= MetNosZ2

CONVERT @VM TO '' IN MetTest
CONVERT @VM TO '' IN Z1Test
CONVERT @VM TO '' IN Z2Test

IF MetTest = '' THEN
	BEGIN CASE
		CASE Z1Test = '' AND Z2Test = ''
			* Ask for z1 or z2
			TypeOver = ''
			TypeOver<MTYPE$>	= 'B&1,&2,&Cancel'
			TypeOver<MCAPTION$>	= 'Add Reactor Zone Metrology'
			TypeOver<MICON$>	= '?'
			TypeOver<MDEFBTN$>	= '3'
			TypeOver<MTEXT$>	= 'Add Metrology for Zone:'
			
			NewZone = Msg(@WINDOW,TypeOver,'')
			
			IF NewZone = 3 THEN RETURN
			
			
		CASE Z1Test = '' AND Z2Test NE ''
			NewZone = 1
			
		CASE Z1Test NE '' AND Z2Test = ''
			NewZone = 2
			
		CASE 1
			ErrMsg('No open Zone to move to.')
			RETURN
			
	END CASE
	
	Send_Event(@WINDOW,'WRITE')
	
	FOR I = 1 TO COUNT(LSIDs,@VM) + (LSIDs NE '')
		IF LSIDs<1,I> NE '' THEN
			LSID = LSIDs<1,I>
			
			oRTParms  = RDSNo:@RM
			oRTParms := LSID:@RM
			oRTParms := PSNo:@RM
			oRTParms := NewZone
			
			obj_RDS_Test('Create',oRTPARms)
		END
	NEXT I
	
	Set_Property(@WINDOW:'.RDS_NO','DEFPROP',RDSNo)
	Send_Event(@WINDOW,'READ')
	
END 
		
RETURN


* * * * * * *
MoveMetToZone:
* * * * * * *

CtrlEntID = @WINDOW:'.RDS_LS_ID'
RDSNo = Get_Property(@WINDOW,'ID')

LSArray = Get_Property(CtrlEntID,'DEFPROP')

MetNos		= LSArray<COL$MET_NO>
MetNosZ1	= LSArray<COL$MET_NO_Z1>
MetNosZ2	= LSArray<COL$MET_NO_Z2>

MetTest	= MetNos
Z1Test	= MetNosZ1
Z2Test	= MetNosZ2

CONVERT @VM TO '' IN MetTest
CONVERT @VM TO '' IN Z1Test
CONVERT @VM TO '' IN Z2Test

IF MetTest NE '' THEN
	BEGIN CASE
		CASE Z1Test = '' AND Z2Test = ''
			* Ask for z1 or z2
			TypeOver = ''
			TypeOver<MTYPE$>	= 'B&1,&2,&Cancel'
			TypeOver<MCAPTION$>	= 'Move  Metrology to Reactor Zone'
			TypeOver<MICON$>	= '?'
			TypeOver<MDEFBTN$>	= '3'
			TypeOver<MTEXT$>	= 'Move Metrology to Zone:'
			
			DestZone = Msg(@WINDOW,TypeOver,'')
			
			IF DestZone = 3 THEN RETURN
			
			
		CASE Z1Test = '' AND Z2Test NE ''
			DestZone = 1
			
		CASE Z1Test NE '' AND Z2Test = ''
			DestZone = 2
			
		CASE 1
			ErrMsg('No open Zone to move to.')
			RETURN
			
	END CASE
	
	Send_Event(@WINDOW,'WRITE')
	
	FOR I = 1 TO COUNT(MetNos,@VM) + (MetNos NE '')
		IF MetNos<1,I> NE '' THEN
			MetNo = MetNos<1,I>
			
			oRTParms  = MetNo:@RM
			oRTParms := DestZone
			
			obj_RDS_Test('SetZone',oRTPARms)
		END
	NEXT I
	
	Set_Property(@WINDOW:'.RDS_NO','DEFPROP',RDSNo)
	Send_Event(@WINDOW,'READ')
	
END 
		

RETURN

* * * * * * *
HoldClick:
* * * * * * *

RDSNo		= Get_Property(@WINDOW:'.RDS_NO','DEFPROP')
WOMatKey	= Get_Property(@WINDOW:'.WO_MAT_KEY','DEFPROP')
CtrlEnt		= Get_Property(@WINDOW,'FOCUS')

Send_Event(@WINDOW,'WRITE')
Send_Event(@WINDOW,'CLEAR') ; // 12/21/2017 - DMB - Although WRITE normally clears the form, QBF mode will prevent the clear so do this explicitly so the lock is removed from the RDS record.

HoldEntity		= 'RDS'
HoldEntityID	= RDSNo

obj_WO_Mat('ToggleHold',WOMatKey:@RM:HoldEntity:@RM:HoldEntityID:@RM:CtrlEnt)

IF Get_Status(errCode) THEN ErrMsg(errCode)

obj_AppWindow('LoadFormKeys',@WINDOW:@RM:RDSNo)

RETURN


* * * * * * *
HoldDC:
* * * * * * *

CtrlEntID = @WINDOW:'.HOLD_HISTORY'
RecordID = Get_Property(@WINDOW:'.RDS_NO','DEFPROP')

WOMatKey	= Get_Property(@WINDOW:'.WO_MAT_KEY','DEFPROP')

HoldHistory = Get_Property(CtrlEntID,'LIST')

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

HistoryCols	= Get_Property(CtrlEntID, "COLUMN")
ColName		= HistoryCols<1,1,CurrCol>


obj_WO_Mat('EditHoldReason',WOMatKey:@RM:ColName:@RM:CurrRow)
IF Get_Status(errCode) THEN ErrMsg(errCode)

Send_Event(CtrlEntID,'CALCULATE',CurrCol)

RETURN



* * * * * * * 
CtrlPlanClick:
* * * * * * *

PSNo = Get_Property(@WINDOW:'.PSN','DEFPROP')
WONo = Get_Property(@WINDOW:'.WO','DEFPROP')

IF PSNo NE '' THEN	
	Print_Control_Plan(PSNo,WONo)
END

RETURN


* * * * * * *
Override:
* * * * * * *

UserRec = XLATE('LSL_USERS',@USER4,'','X')

RDSMasterFlag	= UserRec<LSL_USERS_RDS_MASTER$>
UserGroups		= UserRec<LSL_USERS_GROUPS$>

IF NOT(RDSMasterFlag) THEN
	ErrMsg('You do not have security rights to override Run Data Sheet information.')
	RETURN
END

IF NOT(Dialog_Box( 'PWD_ENTRY', @WINDOW, '' )) THEN RETURN

EpiOvrControls = Get_Property( @WINDOW, '@EpiOvrControls' )  
Set_Property( EpiOvrControls, 'ENABLED', 1 )

LOCATE 'MASTER_SCHED' IN UserGroups USING @VM SETTING Dummy ELSE
	Set_Property(@WINDOW:'.STATUS.CANCELLED','ENABLED',0)				;* Disable the CANCELLED button in the button group
END


RETURN


* * * * * * *
PrintInstruction:
* * * * * * *

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

IF RDSNo NE '' THEN
	Print_RDS_Instruction(RDSNo)
END

RETURN



* * * * * * *
ViewWOMat:
* * * * * * *

Ctrls  = @WINDOW:'.WO':@RM				; Props  = 'DEFPROP':@RM
Ctrls := @WINDOW:'.RUN_ORDER_NUM':@RM	; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.RDS_NO':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.REACTOR':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.WO_STEP':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.REACTOR_TYPE'		; Props := 'DEFPROP'

Vals = Get_Property(Ctrls,Props)

WONo		= Vals[1,@RM]
CassNo		= Vals[COL2()+1,@RM]
RDSNo		= Vals[COL2()+1,@RM]
Reactor		= Vals[COL2()+1,@RM]
WOStep		= Vals[COL2()+1,@RM]
ReactorType	= Vals[COL2()+1,@RM]

IF ReactorType = 'P' OR ReactorType = 'EPP' THEN RETURN

Send_Event(@WINDOW,'WRITE')
Send_Event(@WINDOW,'CLEAR') ; // 12/21/2017 - DMB - Although WRITE normally clears the form, QBF mode will prevent the clear so do this explicitly so the lock is removed from the RDS record.

thisFormWindowUp = Get_Property('WO_MAT_WFR','VISIBLE')	;* Returns 0 = hidden, 1 = visible, 2 = minimized, 3 = maximized 

IF thisFormWindowUp = ''	THEN
	Start_Window('WO_MAT_WFR',@WINDOW,'')
END ELSE

	IF thisFormWindowUp = 2		THEN Set_Property('WO_MAT_WFR','VISIBLE',9)	;* Restore the window if minimized

	IF Get_Property('WO_MAT_WFR','SAVEWARN') THEN
		Set_Property('WO_MAT_WFR','@SKIP_CARD_RETURN',1)	;* This stops the Return behavior
		Send_Event('WO_MAT_WFR','CLEAR')					;* Clear anything existing (prompts for save first)
	END
END
	
* Load Key Controls with Key Parts

Ctrls  = 'WO_MAT_WFR':@RM				; Props  = '@RETURN_KEY':@RM		; Vals  = RDSNo:@RM
Ctrls := 'WO_MAT_WFR':@RM				; Props := '@RETURN_PAGE':@RM		; Vals := '':@RM
Ctrls := 'WO_MAT_WFR':@RM				; Props := '@RETURN_CONTROL':@RM	; Vals := '':@RM
Ctrls := 'WO_MAT_WFR':@RM				; Props := '@RETURN_POS':@RM		; Vals := '':@RM
Ctrls := 'WO_MAT_WFR':@RM				; Props := '@RDS_NO':@RM			; Vals := RDSNo:@RM
Ctrls := 'WO_MAT_WFR':@RM				; Props := '@REACTOR':@RM			; Vals := Reactor:@RM
Ctrls := 'WO_MAT_WFR':@RM				; Props := '@WO_STEP_NO':@RM		; Vals := WOStep:@RM

Ctrls := 'WO_MAT_WFR.WO_NO':@RM			; Props := 'DEFPROP':@RM			; Vals := WONo:@RM
Ctrls := 'WO_MAT_WFR.CASS_NO'			; Props := 'DEFPROP'				; Vals := CassNo
	
Set_Property(Ctrls,Props,Vals)

Send_Event('WO_MAT_WFR.CASS_NO','LOSTFOCUS')
	
RETURN



* * * * * * *
NextStepQty:
* * * * * * *

Ctrls  = @WINDOW:'.RDS_NO':@RM		; Props  = 'DEFPROP':@RM
Ctrls := @WINDOW:'.WO':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.WO_STEP':@RM		; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.CASS_NO'			; Props := 'DEFPROP'

Vals = Get_Property(Ctrls,Props)

CurRDSNo	= Vals[1,@RM]
WONo		= Vals[COL2()+1,@RM]
WOStep		= Vals[COL2()+1,@RM]
CassNo		= Vals[COL2()+1,@RM]


WOMatKey = WONo:'*':CassNo
WOMatRec = XLATE('WO_MAT',WOMatKey,'','X')
WMRDSNos = WOMatRec<WO_MAT_RDS_NO$>

LOCATE CurRdsNo IN WMRDSNos USING @VM SETTING Pos THEN
	NextRDSNo = WMRDSNos<1,Pos+1>
	IF NextRDSNo NE '' THEN
		CurrWfrQty = obj_WO_Mat('CurrWaferCnt',WOMatKey:@RM:WOMatRec)
		Set_Status(0)
		obj_RDS('SetSchedWfrQty',NextRDSNo:@RM:CurrWfrQty)
		IF Get_Status(errCode) THEN ErrMsg(errCode)
	END
END ELSE
	ErrMsg('Not a multi step process')
END

RETURN


* * * * * * *
CIClick:
* * * * * * *


CurrCtrl = Parm1

BEGIN CASE
	CASE @WINDOW = 'RDS_PRE_EPI'
		Stage = 'PRE'
		CICtrl = @WINDOW:'.PRE_CI_NO'
		
	CASE @WINDOW = 'RDS'
		Stage = 'FWI'
		CICtrl = @WINDOW:'.FWI_CI_NO'
		
	CASE @WINDOW = 'RDS_UNLOAD'
		Stage = 'LWI'
		CICtrl = @WINDOW:'.LWI_CI_NO'

	CASE @WINDOW = 'RDS_POST_EPI'
		Stage = 'POST'
		CICtrl = @WINDOW:'.POST_CI_NO'

	CASE 1	; RETURN
	
END CASE

Ctrls  = @WINDOW:'.RDS_NO':@RM		; Props  = 'DEFPROP':@RM
Ctrls := @WINDOW:'.WO':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.WO_STEP':@RM		; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.CASS_NO':@RM		; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.PSN':@RM			; Props := 'DEFPROP':@RM
Ctrls := CICtrl						; Props := 'DEFPROP'

Vals = Get_Property(Ctrls,Props)

RDSNo	= Vals[1,@RM]
WONo	= Vals[COL2()+1,@RM]
WOStep	= Vals[COL2()+1,@RM]
CassNo	= Vals[COL2()+1,@RM]
PSNo	= Vals[COL2()+1,@RM]
CINo	= Vals[COL2()+1,@RM]

IF RDSNo = '' THEN RETURN

IF CINo = '' THEN

	MsgHead	= 'Create Clean_Insp Record'
	MsgText	= 'Are you sure you wish to create a Clean_Insp record for this stage?'

	OK = Msg(@WINDOW,'','YESNO','',MsgHead:@FM:MsgText)
	
	IF NOT(OK) THEN RETURN

	oCIParms  = WONo:@RM
	oCIParms := WOStep:@RM
	oCIParms := CassNo:@RM
	oCIParms := Stage:@RM
	oCIParms := RDSNo:@RM
	oCIParms := PSNo:@RM
	oCIParms := ''			;* PSRec passed as null
	
	CINo = obj_Clean_Insp('Create',oCIParms)
	
	IF Get_Status(errCode) THEN
		ErrMsg(errCode)
		RETURN
	END
	
	obj_React_Run('AddCI',RDSNo:@RM:Stage:@RM:CINo)
	
END

IF CINo NE '' THEN
	
	Send_Event(@WINDOW,'WRITE')
    Send_Event(@WINDOW,'CLEAR') ; // 12/22/2017 - DMB - Although WRITE normally clears the form, QBF mode will prevent the clear so do this explicitly so the lock is removed from the RDS record.

	DetWindow	= 'CLEAN_INSP'
	DetKeys		= CINo
	DefaultRec	= ''
	RetKey		= RDSNo
	RetWin		= @WINDOW
	RetPage		= 1
	RetCtrl		= CurrCtrl
	RetPos		= ''
	
	obj_Appwindow('ViewNewDetail',DetWindow:@RM:DetKeys:@RM:DefaultRec:@RM:RetKey:@RM:RetPage:@RM:RetCtrl:@RM:RetPos)
	
END

RETURN


* * * * * * *
LoadCI:
* * * * * * *

* Dead

RETURN



* * * * * * *
SAPSign:
* * * * * * * 
* Used to auto-sign all steps for Admin purposes.

RDSNo		= Get_Property(@WINDOW:'.RDS_NO','DEFPROP')
WONo		= Get_Property(@WINDOW:'.WO','DEFPROP')
WOStepNo	= Get_Property(@WINDOW:'.WO_STEP','DEFPROP')
CassNo		= Get_Property(@WINDOW:'.CASS_NO','DEFPROP')
SchedQty	= Get_Property(@WINDOW:'.WAFERS_SCHEDULED','DEFPROP')

PRodVerNo = XLATE('WO_LOG',WONo,WO_LOG_PROD_VER_NO$,'X')

IF ProdVerNo = '' THEN
	ErrMsg('No Prod_Ver number on Work Order -> Not generated by SAP.')
	RETURN
END

CurrDt = Date()
CurrTm = Time()

Set_Property(@WINDOW:'.SHIFT','DEFPROP',1)

Send_Event(@WINDOW,'WRITE')

otParms = 'RDS':@RM:RdsNo
RDSRec = obj_Tables('ReadRec',otParms)	;* Reads and sets lock

IF Get_Status(errCode) THEN RETURN			;* Problems getting the lock

* IF @USERNAME = 'BRYCE_BARB' THEN Sig = 'BRYCE_BARB'
* IF @USER4 = 'DAVID_KL'		THEN Sig = 'DAVID_KL'
If MemberOf(@USER4, 'OI_ADMIN') then
    Sig = @USER4
end

AllSigProfKeys = XLATE('WO_MAT',WONo:'*':CassNo,WO_MAT_SIG_PROFILE$,'X')

SigCnt = COUNT(AllSigProfKeys,@VM) + (AllSigProfKeys NE '')

SigDTM = OCONV(Date(),'D4/'):' ':OCONV(Time(),'MTHS')

SigProfKeys = ''
Sigs = ''
SigDTMs = ''

SigProfKeys = AllSigProfKeys

FOR I = 1 TO SigCnt - 1
	*SigProfKeys<1,I> = AllSigProfKeys<1,I>
	Sigs<1,I> = Sig
	SigDTMs<1,I> = SigDTM
NEXT I

RDSRec<RDS_PRE_EPI_SIG$>		= Sig
RDSRec<RDS_PRE_EPI_SIG_DATE$>	= CurrDt
RDSRec<RDS_PRE_EPI_SIG_TIME$>	= CurrTm - 250

RDSRec<RDS_OPERATOR_IN$>		= Sig
RDSRec<RDS_DATE_IN$>			= CurrDt
RDSRec<RDS_TIME_IN$>			= CurrTm - 200

RDSRec<RDS_FIRST_WAF_SIG$>		= Sig
RDSRec<RDS_FIRST_WAF_SIG_DATE$>	= CurrDt
RDSRec<RDS_FIRST_WAF_SIG_TIME$> = CurrTm - 150

RDSRec<RDS_OPERATOR_OUT$>		= Sig
RDSRec<RDS_DATE_OUT$>			= CurrDt
RDSRec<RDS_TIME_OUT$>			= CurrTm - 100

RDSRec<RDS_POST_EPI_SIG$>		= Sig
RDSRec<RDS_POST_EPI_SIG_DATE$>	= CurrDt
RDSRec<RDS_POST_EPI_SIG_TIME$>	= CurrTm - 50

* RDSRec<RDS_SUP_VER_SIG$>		= Sig
* RDSRec<RDS_SUP_VER_SIG_DATE$>	= CurrDt
* RDSRec<RDS_SUP_VER_SIG_TIME$>	= CurrTm - 25

RDSRec<RDS_STATUS$>	= 'T'

RDSRec<RDS_VERIFY_QTY$>	= SchedQty
RDSRec<RDS_WAFERS_IN$>	= SchedQty
RDSRec<RDS_WAFERS_OUT$>	= SchedQty      


otParms = FIELDSTORE(otParms,@RM,4,0,RDSRec)
obj_Tables('WriteRec',otParms)
	
	
IF Get_Status(errCode) THEN
	obj_Tables('UnlockRec',otParms)
END

* obj_WO_Mat('SetSignature',WONo:@RM:CassNo:@RM:WOStepNo:@RM:SigProfKeys:@RM:Sigs:@RM:SigDTMs)	;* Clears the WO_MAT signature

IF Get_Status(errCode) THEN
	ErrMsg(errCode)
END



LogFile = 'WO_MAT'
Action = 'Place'
WhCd	= '1K'		;* Class 1000 room
LocCd	= 'PTI'		;* Passthrough Inbound
WONos	= WONo
CassNos = CassNo
UserID  = Sig
CassIDs	= RDSNo

obj_WO_Mat_Log('Create',LogFile:@RM:SigDTM:@RM:Action:@RM:WhCd:@RM:LocCd:@RM:WONos:@RM:CassNos:@RM:UserID:@RM:CassIDs)

IF Get_Status(errCode) THEN
	ErrMsg(errCode)
END

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

RETURN


* * * * * * *
SAPReject:
* * * * * * * 

* Rejected cassettes do not close automatically.  This is the manual step triggered by the 
* SAP "Reject" button on the RDS_POST_EPI window.  Admin reviews and then closes and data is sent
* to SAP and Fab-Time.


* Following copied from Sign Final QA click event on the RDS_POST_EPI window.

* Development in process 10/23/2014 JC

IF @USERNAME = 'BRYCE_BARB' THEN @USER4 = 'BRYCE_BARB'

SigDt = OCONV( Date(), 'D2/' )
			
SigTm 			= Time()
SigTmPlusOne	= OCONV(SigTm + 1, 'MTS' )
SigTmPlusTwo	= OCONV(SigTm + 2, 'MTS' )
SigTm			= OCONV(SigTm,'MTS')

SigBy = @USER4

Ctrls  = @WINDOW:'.REACTOR_TYPE':@RM	; Props  = 'DEFPROP':@RM
Ctrls := @WINDOW:'.RDS_NO':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.WO':@RM				; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.WO_STEP':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.CASS_NO':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.MAKEUP_BOX'			; Props := 'CHECK'

Vals = Get_Property(Ctrls,Props)

ReactorType = Vals[1,@RM]
CurRDSNo	= Vals[COL2()+1,@RM]
WONo		= Vals[COL2()+1,@RM]
WOStep		= Vals[COL2()+1,@RM]
CassNo		= Vals[COL2()+1,@RM]
MakeupBox	= Vals[COL2()+1,@RM]


EventParms = ''
EventCnt   = 1

IF ReactorType NE 'EPP' THEN

	ToolID		= ''
	WHCd		= 'CR'
	LocCD		= 'QA'
	Tag			= ''

	owmParms = WONo:@RM:CassNo:@RM:WOStep:@RM:'QA':@RM:@USER4:@RM:SigDt:' ':SigTm:@RM:ToolID:@RM:WHCd:@RM:LocCd:@RM:Tag			;* 4/30/2013 JCH added parms for merging of two methods	
	
* 	obj_WO_Mat('SetSignature',owmParms)		; * * * * * S I G N A T U R E  * * * * * *
	
	IF Get_Status(errCode) THEN
		CALL ErrMsg(ErrCode)
		RETURN 0					;* Added 4/4/2013 JCH
	END
		
	EventParms<COL$LOG_FILE>		= 'WO_MAT'
	EventParms<COL$LOG_DTM>			= SigDt:' ':SigTm
	EventParms<COL$WO_MAT_ACTION>	= WOStep:'QA'
	EventParms<COL$WH_CD>			= 'CR'
	EventParms<COL$LOC_CD>			= 'QA'
	EventParms<COL$WO_NOS>			= WONo
	EventParms<COL$CASS_NOS>		= CassNo
	EventParms<COL$USER_ID>			= @USER4
	EventParms<COL$TAGS>			= ''
	EventParms<COL$TOOL_ID>			= ''
	
	CONVERT @FM TO @RM IN EventParms
	
	obj_WO_Mat_Log('Create',EventParms)		;* * * * * INV EVENT LOG * * * * *
	
	IF Get_Status(errCode) THEN
		CALL ErrMsg(ErrCode)
		RETURN 0
	END
	
	IF MakeupBox = 1 THEN
		
		EventParms<COL$LOG_FILE>		= 'WO_MAT'
		EventParms<COL$LOG_DTM>			= SigDt:' ':SigTmPlusTwo
		EventParms<COL$WO_MAT_ACTION>	= 'RTU'
		EventParms<COL$WH_CD>			= 'CR'
		EventParms<COL$LOC_CD>			= 'MU'
		EventParms<COL$WO_NOS>			= WONo
		EventParms<COL$CASS_NOS>		= CassNo
		EventParms<COL$USER_ID>			= @USER4
		EventParms<COL$TAGS>			= ''
		EventParms<COL$TOOL_ID>			= ''
		
		CONVERT @FM TO @RM IN EventParms
		
		obj_WO_Mat_Log('Create',EventParms)		;* * * * * INV EVENT LOG * * * * *
		
		IF Get_Status(errCode) THEN
			CALL ErrMsg(ErrCode)
			RETURN 0
		END
		
	END
	
END	;* End of check for non EpiPRO reactor


* Update Final QA signature fields in the window *

Ctrls  = @WINDOW:'.POST_EPI_SUP_SIG':@RM		; Props  = 'TEXT':@RM		; Vals  = @USER4:@RM
Ctrls := @WINDOW:'.POST_EPI_SUP_SIG_NAME':@RM	; Props := 'TEXT':@RM		; Vals := OCONV( @USER4, '[XLATE_CONV,LSL_USERS*FIRST_LAST]' ):@RM
Ctrls := @WINDOW:'.POST_EPI_SUP_SIG_DATE':@RM	; Props := 'TEXT':@RM		; Vals := SigDt:@RM
Ctrls := @WINDOW:'.POST_EPI_SUP_SIG_TIME'		; Props := 'TEXT'			; Vals := SigTmPlusOne

Set_Property(Ctrls,Props,Vals)


* Check for multiple Reactor Runs on this cassette and update Sched Wafer Qty as required *

WOMatKey = WONo:'*':CassNo
WOMatRec = XLATE('WO_MAT',WOMatKey,'','X')
WMRDSNos = WOMatRec<WO_MAT_RDS_NO$>
				
LOCATE CurRdsNo IN WMRDSNos USING @VM SETTING Pos THEN
	NextRDSNo = WMRDSNos<1,Pos+1>
					
	IF NextRDSNo NE '' THEN
		CurrWfrQty = obj_WO_Mat('CurrWaferCnt',WOMatKey:@RM:WOMatRec)
		Set_Status(0)
		obj_RDS('SetSchedWfrQty',NextRDSNo:@RM:CurrWfrQty)
		IF Get_Status(errCode) THEN ErrMsg(errCode)
	END
END


WOMatKey	= WONo:'*':CassNo
OrgMUPart	= XLATE('WO_MAT',WOMatKey,'MU_PART_NO','X')

Send_Event(@WINDOW,'WRITE')


* Generate index transaction to keep the MU_PART_NO index updated in the WO_MAT table *

NewMUPart = XLATE('WO_MAT',WOMatKey,'MU_PART_NO','X')

IF NewMUPart NE OrgMUPart THEN

	IndexTransactionRow = 'MU_PART_NO':@FM:WOMatKey:@FM:OrgMUPart:@FM:NewMUPart:@FM
	
	OPEN "!WO_MAT" TO BangTable THEN

		LOCK BangTable, 0 THEN

			READ PendingTrans FROM BangTable, 0 ELSE PendingTrans = '0':@FM
			
			PendingTrans := IndexTransactionRow
			
			WRITE PendingTrans ON BangTable, 0 ELSE
				ErrMsg('Unable to write index transaction to !WO_MAT. ':WOMatKey)
			END
			UNLOCK BangTable, 0 ELSE ErrMsg('Unable to Open !WO_MAT to add index transaction. ':WOMatKey)
		END ELSE
			ErrMsg('Unable to Lock !WO_MAT to add index transaction. ':WOMatKey)
		END
	END ELSE
		ErrMsg('Unable to Open !WO_MAT to add index transaction. ':WOMatKey)
	END
END	;* End of check for changed index value


* Redisplay the updated RDS record in the window *

obj_AppWindow('LoadFormKeys',@WINDOW:@RM:CurRdsNo)



RETURN




* * * * * * *
MetTestDC:
* * * * * * *

Ctrls  = @WINDOW:'.RDS_NO':@RM		; Props  = 'DEFPROP':@RM
Ctrls := @WINDOW:'.WO':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.WO_STEP':@RM		; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.CASS_NO':@RM		; Props := 'DEFPROP':@RM
* If @USER4 EQ 'FRANCOIS_R' then
    Ctrls := @WINDOW:'.EDT_QA_MET':@RM	; Props := 'SELPOS':@RM
    Ctrls := @WINDOW:'.EDT_QA_MET'		; Props := 'LIST'
* end else
*    Ctrls := @WINDOW:'.MET_TEST':@RM	; Props := 'SELPOS':@RM
*    Ctrls := @WINDOW:'.MET_TEST'		; Props := 'LIST'
* end

Vals = Get_Property(Ctrls,Props)

RDSNo	= Vals[1,@RM]
WONo	= Vals[COL2()+1,@RM]
WOStep	= Vals[COL2()+1,@RM]
CassNo	= Vals[COL2()+1,@RM]
CurrPos	= Vals[COL2()+1,@RM]
Lines	= Vals[COL2()+1,@RM]

CurrCol = CurrPos<1>
CurrRow = CurrPos<2>

TestLine = Lines<CurrRow>

CurrCtrl = Get_Property(@WINDOW,'FOCUS')

RunStep = ''
If CurrCtrl[1,'.'] = 'RDS' Then RunStep = 'FWI'
IF CurrCtrl[1,'.'] = 'RDS_UNLOAD' THEN RunStep = 'UNLOAD'
IF CurrCtrl[1,'.'] = 'RDS_POST_EPI' THEN RunStep = 'QA'

IF RunStep = '' THEN RETURN

CassID = WONo:'*':WOStep:'*':CassNo:'*':RDSNo:'*':RunStep

BEGIN CASE
 
 	CASE @WINDOW = 'RDS_UNLOAD' ;//and @USER4 EQ 'FRANCOIS_R' 
		ReturnVal = Dialog_Box( 'NDW_QA_MET_RESULT', @WINDOW, CassID)

	CASE Otherwise$
	    ReturnVal = Dialog_Box('QA_MET_RESULT', @WINDOW, CassID:@FM:TestLine)
	
END CASE

GOSUB Refresh

RETURN


* * * * * * * *
LUPostCode:
* * * * * * * *

ToolKeys		= XLATE('TOOL_CLASS','AKRION',TOOL_CLASS_TOOL$,'X')
ToolKeys<1,-1>	= XLATE('TOOL_CLASS','WET BENCH',TOOL_CLASS_TOOL$,'X')

TypeOver = ''
TypeOver<PMODE$> = 'K'
TypeOver<PDISPLAY$> = ToolKeys

ToolID = Popup(@WINDOW,TypeOver,'TOOLS')

IF ToolID = '' THEN RETURN

obj_Appwindow('LUValReturn',ToolID:@RM:@WINDOW:'.POST_CODE')


RETURN

* * * * * * *
SigProfile:
* * * * * * *

WONo = Get_Property(@WINDOW:'.WO','TEXT')
CassNo = Get_Property(@WINDOW:'.CASS_NO','TEXT')
WOStep = Get_Property(@WINDOW:'.WO_STEP','TEXT')


IF WONo = '' OR CassNo = '' THEN RETURN

SigData = obj_WO_Mat('GetSigProfile',WONo:'*':CassNo:@RM:WOStep)

Display = ''
RowCnt = COUNT(SigData<1>,@VM) + (SigData<1> NE '')

FOR I = 1 TO RowCnt
	Display<1,I,1> = SigData<1,I>
	Display<1,I,2> = SigData<2,I>
	Display<1,I,3> = SigData<3,I>
	Display<1,I,4> = SigData<4,I>
NEXT I

TypeOver = ''
TypeOver<PDISPLAY$> = Display

void = Popup(@WINDOW,TypeOver,'SIG_PROFILE')

RETURN


* * * * * * *
ReactProfile:
* * * * * * *

ReactNo = Get_Property(@WINDOW:'.REACTOR','DEFPROP')

IF ReactNo NE '' THEN
	obj_AppWindow('ViewRelated','REACT_STATE':@RM:ReactNo)
END

RETURN


* * * * * * * *
ConversionLoad:
* * * * * * * *

* Routine to create/update RDS_LAYER and RDS_TEST records until conversion is complete
* dead stub

RETURN




