COMPILE FUNCTION obj_React_Run_CI(Method,Parms)

/*
	Methods for REACT_RUN_CI table
    
	02/21/2008 JCH - Initial Coding
     
    Properties:
     
    Methods:
    
    Create(DataStruct)		;* Create new record
	
	
*/


DECLARE FUNCTION Get_Status, Msg, Utility, obj_Tables, NextKey,  obj_Prod_Spec, Send_Dyn
DECLARE FUNCTION obj_RDS_Test, Environment_Services
DECLARE SUBROUTINE  Set_Status, Msg, obj_Tables, Send_Dyn, obj_WO_Step, obj_RDS_Layer, obj_RDS_Test, obj_WM_In
DECLARE SUBROUTINE ErrMsg

$INSERT MSG_EQUATES
$INSERT DICT_EQUATES

$INSERT REACT_RUN_CI_EQUATES
$INSERT QUOTE_SPEC_EQU
$INSERT PROD_SPEC_EQUATES

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

$INSERT PRS_LAYER_EQU	;* Used to return obj_Prod_Spec_CI values

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

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

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

Result = ''

BEGIN CASE
	CASE Method = 'Create'			; GOSUB Create
	CASE Method = 'Desc'			; GOSUB Desc
	CASE Method = 'Delete'			; GOSUB Delete
	CASE Method = 'CurrStatus'		; GOSUB CurrStatus
	CASE Method = 'SendToSPC'		; GOSUB SendToSPC
	CASE 1
		

END CASE

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

RETURN Result




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

CIKey	= Parms[1,@RM]
RunNo	= Parms[COL2()+1,@RM]
PSRec	= Parms[COL2()+1,@RM]

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

IF ErrorMsg NE '' THEN RETURN

ReactorType = PSRec<PROD_SPEC_REACTOR_TYPE$>							;* Not used in this program 9/2/2014 JCH

CompWaferSize = PSRec<PROD_SPEC_SPEC_SUBSTRATE$,QSSubWaferSize$>		;* looks like "5 in 125 mm"


RunCIRec = ''
RunCIRec<REACT_RUN_CI_RDS_NO$>		= RunNo
RunCIRec<REACT_RUN_CI_WAFER_SIZE$>	= CompWaferSize				;* Added 10/29/2008 JCH

IF FIELD(CIKey,'*',4) = 'PRE' THEN
	
	
	RunCIRec<REACT_RUN_CI_SPEC_BRIGHTLIGHT$>			= PSRec<PROD_SPEC_PRE_BRIGHTLIGHT$>
	RunCIRec<REACT_RUN_CI_SPEC_MICROSCOPE$>				= PSRec<PROD_SPEC_PRE_MICROSCOPE$>
	RunCIRec<REACT_RUN_CI_SPEC_SURFSCAN$>				= PSRec<PROD_SPEC_PRE_SURFSCAN$>
	RunCIRec<REACT_RUN_CI_SPEC_SURFSCAN_RECIPE$>		= PSRec<PROD_SPEC_PRE_SURFSCAN_RECIPE$>
	RunCIRec<REACT_RUN_CI_SPEC_CLEAN_SUBOXIDE$>			= PSRec<PROD_SPEC_SPEC_SUBSTRATE$,QSSubOxide$>
	RunCIRec<REACT_RUN_CI_SPEC_CLEAN_OXIDE_ANGSTROMS$>	= PSRec<PROD_SPEC_SPEC_SUBSTRATE$,QSSubOxideAngstroms$>
	RunCIRec<REACT_RUN_CI_SPEC_CLEAN_TOOL$>				= PSRec<PROD_SPEC_SPEC_SUBSTRATE$,QSSubPreClean$>
	RunCIRec<REACT_RUN_CI_SPEC_CLEAN_AKRION_RECIPE$>	= PSRec<PROD_SPEC_SPEC_SUBSTRATE$,QSSubPreAkrionRecipe$>
	RunCIRec<REACT_RUN_CI_SPEC_SURF_HAZE$>				= PSRec<PROD_SPEC_PRE_SURF_HAZE$>
	RunCIRec<REACT_RUN_CI_SPEC_SURF_DEFECTS$>			= PSRec<PROD_SPEC_PRE_SURF_DEFECTS$>
	RunCIRec<REACT_RUN_CI_SPEC_PITS$>					= PSRec<PROD_SPEC_PRE_PITS$>
	RunCIRec<REACT_RUN_CI_SPEC_MOUNDS$>					= PSRec<PROD_SPEC_PRE_MOUNDS$>
	RunCIRec<REACT_RUN_CI_SPEC_BL_DEFECTS$>				= PSRec<PROD_SPEC_PRE_BL_DEFECTS$>
	RunCIRec<REACT_RUN_CI_SPEC_SPOTS$>					= PSRec<PROD_SPEC_PRE_SPOTS$>
	RunCIRec<REACT_RUN_CI_SPEC_FOV$>					= PSRec<PROD_SPEC_PRE_FOV$>
	RunCIRec<REACT_RUN_CI_SPEC_SCRATCHES$>				= PSRec<PROD_SPEC_PRE_SCRATCHES$>
	RunCIRec<REACT_RUN_CI_SPEC_SCRATCH_LEN$>			= PSRec<PROD_SPEC_PRE_SCRATCH_LEN$>
	RunCIRec<REACT_RUN_CI_SPEC_LPD$>					= PSRec<PROD_SPEC_PRE_LPD$>	
	
END

IF FIELD(CIKey,'*',4)[1,3] = 'WFR' THEN	
		
	RunCIRec<REACT_RUN_CI_SPEC_BRIGHTLIGHT$>			= PSRec<PROD_SPEC_FIRST_BRIGHTLIGHT$>
	RunCIRec<REACT_RUN_CI_SPEC_MICROSCOPE$>				= PSRec<PROD_SPEC_FIRST_MICROSCOPE$>
	RunCIRec<REACT_RUN_CI_SPEC_SURFSCAN$>				= PSRec<PROD_SPEC_FIRST_SURFSCAN$>
	RunCIRec<REACT_RUN_CI_SPEC_SURFSCAN_RECIPE$>		= PSRec<PROD_SPEC_FIRST_SURFSCAN_RECIPE$>
	RunCIRec<REACT_RUN_CI_SPEC_CLEAN_TOOL$>				= PSRec<PROD_SPEC_SPEC_SUBSTRATE$,QSSubPostClean$>
	RunCIRec<REACT_RUN_CI_SPEC_CLEAN_AKRION_RECIPE$>	= PSRec<PROD_SPEC_SPEC_SUBSTRATE$,QSSubPostAkrionRecipe$>
	RunCIRec<REACT_RUN_CI_SPEC_SURF_HAZE$>				= PSRec<PROD_SPEC_POST_SURF_HAZE$>
	RunCIRec<REACT_RUN_CI_SPEC_SURF_DEFECTS$>			= PSRec<PROD_SPEC_POST_SURF_DEFECTS$>
	RunCIRec<REACT_RUN_CI_SPEC_PITS$>					= PSRec<PROD_SPEC_POST_PITS$>
	RunCIRec<REACT_RUN_CI_SPEC_MOUNDS$>					= PSRec<PROD_SPEC_POST_MOUNDS$>
	RunCIRec<REACT_RUN_CI_SPEC_BL_DEFECTS$>				= PSRec<PROD_SPEC_POST_BL_DEFECTS$>
	RunCIRec<REACT_RUN_CI_SPEC_SPOTS$>					= PSRec<PROD_SPEC_POST_SPOTS$>
	RunCIRec<REACT_RUN_CI_SPEC_FOV$>					= PSRec<PROD_SPEC_POST_FOV$>
	RunCIRec<REACT_RUN_CI_SPEC_SCRATCHES$>				= PSRec<PROD_SPEC_POST_SCRATCHES$>
	RunCIRec<REACT_RUN_CI_SPEC_SCRATCH_LEN$>			= PSRec<PROD_SPEC_POST_SCRATCH_LEN$>
	RunCIRec<REACT_RUN_CI_SPEC_LPD$>					= PSRec<PROD_SPEC_POST_LPD$>
	RunCIRec<REACT_RUN_CI_SPEC_STACK_FAULTS$>			= PSRec<PROD_SPEC_POST_STACK_FAULTS$>
	RunCIRec<REACT_RUN_CI_SPEC_SPIKES$>					= PSRec<PROD_SPEC_POST_SPIKES$>
	RunCIRec<REACT_RUN_CI_SPEC_FWI_LWI$>				= PSRec<PROD_SPEC_POST_FWI_LWI$>

END

IF FIELD(CIKey,'*',4) = 'POST' THEN

	RunCIRec<REACT_RUN_CI_SPEC_BRIGHTLIGHT$>			= PSRec<PROD_SPEC_POST_CLEAN_BRIGHTLIGHT$>
	RunCIRec<REACT_RUN_CI_SPEC_SURFSCAN$>				= PSRec<PROD_SPEC_POST_CLEAN_SURFSCAN$>
	RunCIRec<REACT_RUN_CI_SPEC_SURFSCAN_RECIPE$>		= PSRec<PROD_SPEC_POST_CLEAN_SURFSCAN_RECIPE$>
	
	RunCIRec<REACT_RUN_CI_SPEC_SURF_HAZE$>				= PSRec<PROD_SPEC_POST_CLEAN_SURF_HAZE$>
	RunCIRec<REACT_RUN_CI_SPEC_SURF_DEFECTS$>			= PSRec<PROD_SPEC_POST_CLEAN_SURF_DEFECTS$>
	RunCIRec<REACT_RUN_CI_SPEC_SS_SAMP_QTY$>			= PSRec<PROD_SPEC_POST_CLEAN_SS_SAMP_QTY$>

END

obj_Tables('WriteRec','REACT_RUN_CI':@RM:CIKey:@RM:@RM:RunCIRec)


RETURN


* * * * * * *
Desc:
* * * * * * *

CIKey = Parms[1,@RM]
CIRec = Parms[COL2()+1,@RM]

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

IF CIRec = '' THEN CIRec = XLATE('REACT_RUN_CI',CIKey,'','X')

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

IF ErrorMsg NE '' THEN RETURN

Stage		= FIELD(CIKey,'*',4)
SpecFwiLwi	= CIRec<REACT_RUN_CI_SPEC_FWI_LWI$>

COxide		= CIRec<REACT_RUN_CI_SPEC_CLEAN_SUBOXIDE$>
CAngstroms	= CIRec<REACT_RUN_CI_SPEC_CLEAN_OXIDE_ANGSTROMS$>
CTool		= CIRec<REACT_RUN_CI_SPEC_CLEAN_TOOL$>
COxide		= CIRec<REACT_RUN_CI_SPEC_CLEAN_AKRION_RECIPE$>

IF CTool = 'No' THEN CTool = ''

IBrightlight	= CIRec<REACT_RUN_CI_SPEC_BRIGHTLIGHT$>
IMicroscope		= CIRec<REACT_RUN_CI_SPEC_MICROSCOPE$>

Surfscan		= CIRec<REACT_RUN_CI_SPEC_SURFSCAN$>
SurfscanRecipe	= CIRec<REACT_RUN_CI_SPEC_SURFSCAN_RECIPE$>

BEGIN CASE
	CASE Stage = 'PRE'							; LabelText = 'Pre Epi '
	CASE Stage = 'POST'							; LabelText = 'Post Epi '
	CASE Stage = 'WFR' AND SpecFwiLwi = 'FWI'	; LabelText = 'First Wafer '
	CASE Stage = 'WFR' AND SpecFwiLwi = 'LWI'	; LabelText = 'Last Wafer '
	CASE Stage[1,3] = 'WFR'						; LabelText = 'Wafer ':Stage[4,99]:' Extra '
	CASE 1										; LabelText = 'Cleaning && Inspection'
END CASE


IF COxide OR CAngstroms OR Ctool OR COxide	THEN CleanText = 'Cleaning '	ELSE CleanText = ''
IF IBrightLight OR IMicroscope	THEN InspText = ' Inspection'				ELSE InspText = ''
IF Surfscan OR SurfscanRecipe	THEN ScanText = ' Surfscan'					ELSE ScanText = ''

IF CleanText NE '' THEN
	LabelText := CleanText
	IF InspText NE '' THEN LabelText := '&& ':InspText
	IF ScanText NE '' THEN LabelText := '&& ':ScanText
END ELSE
	IF InspText NE '' THEN
		LabelText := InspText
		IF ScanText NE '' THEN LabelText := '& ':ScanText
	END ELSE
		IF ScanText NE '' THEN LabelText := ScanText
	END
END

Result = LabelText

RETURN


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

CIKey = Parms[1,@RM]
CIRec = Parms[COL2()+1,@RM]

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

IF CIRec = '' THEN CIRec = XLATE('REACT_RUN_CI',CIKey,'','X')

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

IF ErrorMsg NE '' THEN RETURN

Stage		= FIELD(CIKey,'*',4)

COxide		= CIRec<REACT_RUN_CI_SPEC_CLEAN_SUBOXIDE$>
CAngstroms	= CIRec<REACT_RUN_CI_SPEC_CLEAN_OXIDE_ANGSTROMS$>
CTool		= CIRec<REACT_RUN_CI_SPEC_CLEAN_TOOL$>
COxide		= CIRec<REACT_RUN_CI_SPEC_CLEAN_AKRION_RECIPE$>	;********************* fix this !!!!!!!!!!!!!!!!!!!!

IF CTool[1,2] = 'No' OR CTool[1,2] = 'If' THEN CTool = ''

IBrightlight	= CIRec<REACT_RUN_CI_SPEC_BRIGHTLIGHT$>
IMicroscope		= CIRec<REACT_RUN_CI_SPEC_MICROSCOPE$>

Surfscan		= CIRec<REACT_RUN_CI_SPEC_SURFSCAN$>
SurfscanRecipe	= CIRec<REACT_RUN_CI_SPEC_SURFSCAN_RECIPE$>

IF COxide OR CAngstroms OR CTool OR COxide	THEN

	IF CIRec<REACT_RUN_CI_CLEAN_SIG$> = '' AND CTool NE '' THEN
 		Result = 'RTC'
 		RETURN
	END 
END

IF IBrightLight OR IMicroscope	THEN

	NoSpec = 1
	
	IF CIRec<REACT_RUN_CI_SPEC_LPD$> NE '' 			THEN NoSpec = 0
	IF CIRec<REACT_RUN_CI_SPEC_PITS$> NE ''			THEN NoSpec = 0
	IF CIRec<REACT_RUN_CI_SPEC_MOUNDS$> NE ''		THEN NoSpec = 0
	IF CIRec<REACT_RUN_CI_SPEC_BL_DEFECTS$> NE ''	THEN NoSpec = 0
	IF CIRec<REACT_RUN_CI_SPEC_STACK_FAULTS$> NE ''	THEN NoSpec = 0
	IF CIRec<REACT_RUN_CI_SPEC_SPIKES$> NE ''		THEN NoSpec = 0
	IF CIRec<REACT_RUN_CI_SPEC_SPOTS$> NE ''		THEN NoSpec = 0
	IF CIRec<REACT_RUN_CI_SPEC_FOV$> NE ''			THEN NoSpec = 0
	IF CIRec<REACT_RUN_CI_SPEC_SCRATCHES$> NE ''	THEN NoSpec = 0
	IF CIRec<REACT_RUN_CI_SPEC_SCRATCH_LEN$> NE ''	THEN NoSpec = 0
	
	IF NoSpec THEN
		Result = 'RTI'
		RETURN
	END

	SurfaceComp = 1
	IF CIRec<REACT_RUN_CI_SPEC_LPD$> NE '' 			AND CIRec<REACT_RUN_CI_LPD_IN$>  = '' 		THEN SurfaceComp = 0
	IF CIRec<REACT_RUN_CI_SPEC_PITS$> NE ''			AND CIRec<REACT_RUN_CI_PITS$> = ''			THEN SurfaceComp = 0
	IF CIRec<REACT_RUN_CI_SPEC_MOUNDS$> NE ''		AND CIRec<REACT_RUN_CI_MOUNDS$> = ''		THEN SurfaceComp = 0
	IF CIRec<REACT_RUN_CI_SPEC_BL_DEFECTS$> NE ''	AND CIRec<REACT_RUN_CI_BL_DEFECTS$> = ''	THEN SurfaceComp = 0
	IF CIRec<REACT_RUN_CI_SPEC_STACK_FAULTS$> NE ''	AND CIRec<REACT_RUN_CI_STACK_FAULTS$> = ''	THEN SurfaceComp = 0
	IF CIRec<REACT_RUN_CI_SPEC_SPIKES$> NE ''		AND CIRec<REACT_RUN_CI_SPIKES$> = ''		THEN SurfaceComp = 0
	IF CIRec<REACT_RUN_CI_SPEC_SPOTS$> NE ''		AND CIRec<REACT_RUN_CI_SPOTS$> = ''			THEN SurfaceComp = 0
	IF CIRec<REACT_RUN_CI_SPEC_FOV$> NE ''			AND CIRec<REACT_RUN_CI_FOV$> = ''			THEN SurfaceComp = 0
	IF CIRec<REACT_RUN_CI_SPEC_SCRATCHES$> NE ''	AND CIRec<REACT_RUN_CI_SCRATCHES$> = ''		THEN SurfaceComp = 0
	IF CIRec<REACT_RUN_CI_SPEC_SCRATCH_LEN$> NE ''	AND CIRec<REACT_RUN_CI_SCRATCH_LEN$> = ''	THEN SurfaceComp = 0
	
	IF SurfaceComp = 0 THEN
		Result = 'RTI'
		RETURN
	END
END

IF Surfscan OR SurfscanRecipe THEN
	SpecSurfDef	= OCONV(CIRec<REACT_RUN_CI_SPEC_SURF_DEFECTS$>,'MD0')
	
	SurfDefMax	= OCONV(CIRec<REACT_RUN_CI_SS_SUM_OF_DEF_MAX$>,'MD0')
	SurfDefAvg	= OCONV(CIRec<REACT_RUN_CI_SS_SUM_OF_DEF_AVG$>,'MD3')
	
	SpecSurfHaze	= OCONV(CIRec<REACT_RUN_CI_SPEC_SURF_HAZE$>,'MD2')
	SurfHazeAvgAvg	= OCONV( CIRec<REACT_RUN_CI_SS_HAZE_AVG_AVG$>,'MD3')
	
	IF SpecSurfDef NE '' THEN
		IF SurfDefMax NE '' THEN
			IF SurfDefMax GE SpecSurfDef THEN
				Result = 'OUT'
				RETURN
			END
		END
		IF SurfDefAvg NE '' THEN
			IF SurfDefAvg GE SpecSurfDef THEN
				Result = 'OUT'
				RETURN
			END
		END
	END
			
	IF SpecSurfHaze NE '' THEN
		IF SurfHazeAvgAvg NE '' THEN
			IF SurfHazeAvgAvg GE SpecSurfHaze THEN
				Result = 'OUT'
				RETURN
			END
		END
	END
	
	IF CIRec<REACT_RUN_CI_SS_SUM_OF_DEF_MIN$> = '' THEN
		IF CIRec<REACT_RUN_CI_SS_SUM_OF_DEF_MAX$> = '' THEN
			IF CIRec<REACT_RUN_CI_SS_SUM_OF_DEF_AVG$> = '' THEN
				Result = 'RTS'
				RETURN
			END
		END
	END
	
END


 
RETURN


* * * * * * *
Delete:
* * * * * * *

RRCIKeys = Parms[1,@RM]

IF RRCIKeys = '' THEN RETURN

CONVERT @VM:@SVM TO @FM:@FM IN RRCIKeys

OPEN 'REACT_RUN_CI' TO CIFile THEN
	KeyCnt = COUNT(RRCIKeys,@FM) + (RRCIKeys NE '')
	FOR I = 1 TO KeyCnt
		DELETE CIFile,RRCIKeys<I> ELSE NULL
	NEXT I
END

RETURN



* * * * * * *
SendToSPC:
* * * * * * *

DEBUG

ReactRunCIKey = Parms[1,@RM]

RRCIRec = XLATE('REACT_RUN_CI',ReactRunCIKey,'','X')

RRParms = 'REACT_RUN':@RM:ReactRunCIKey
RRCIRec = obj_Tables('ReadRec',RRParms)

IF Get_Status(errCode) THEN RETURN

DictInfo = XLATE('DICT.RDS_LAYER','%FIELDS%','','X')


RDSNo			= RRCIRec<REACT_RUN_CI_RDS_NO$>
Stage			= ReactRunCIKey[-1,'B*']				;* Last part of the four part key
ScanTool		= RRCIRec<REACT_RUN_CI_SS_SCAN_TOOL$>

ReactNo			= XLATE('REACT_RUN_CI',ReactRunCIKey,'REACT_NO','X')
WaferSize		= RRCIRec<REACT_RUN_CI_WAFER_SIZE$>

WaferSize = WaferSize[1,' ']		;* Data looks like "125 mm 6 in"
UserName = OCONV(@USER4,'[XLATE_CONV,LSL_USERS*FIRST_LAST]')


LOCATE REACT_RUN_CI_SS_SUM_OF_DEF_MIN$ IN DictInfo<FIELDS_FIELD_NO$> SETTING Pos THEN
	SumOfDefMin	= OCONV(RRCIRec<REACT_RUN_CI_SS_SUM_OF_DEF_MIN$>,DictInfo<FIELDS_CONV$,Pos>)
END ELSE
	SumOfDefMin = RRCIRec<REACT_RUN_CI_SS_SUM_OF_DEF_MIN$>
END

LOCATE REACT_RUN_CI_SS_SUM_OF_DEF_MAX$ IN DictInfo<FIELDS_FIELD_NO$> SETTING Pos THEN
	SumOfDefMax = OCONV(RRCIRec<REACT_RUN_CI_SS_SUM_OF_DEF_MAX$>,DictInfo<FIELDS_CONV$,Pos>)
END ELSE
	SumOfDefMax = RRCIRec<REACT_RUN_CI_SS_SUM_OF_DEF_MAX$>
END

LOCATE REACT_RUN_CI_SS_SUM_OF_DEF_AVG$ IN DictInfo<FIELDS_FIELD_NO$> SETTING Pos THEN
	SumOfDefAvg = OCONV(RRCIRec<REACT_RUN_CI_SS_SUM_OF_DEF_AVG$>,DictInfo<FIELDS_CONV$,Pos>)
END ELSE
	SumOfDefAvg = RRCIRec<REACT_RUN_CI_SS_SUM_OF_DEF_AVG$>
END

LOCATE REACT_RUN_CI_SS_HAZE_AVG_AVG$ IN DictInfo<FIELDS_FIELD_NO$> SETTING Pos THEN
	HazeAvgAvg = OCONV(RRCIRec<REACT_RUN_CI_SS_HAZE_AVG_AVG$>,DictInfo<FIELDS_CONV$,Pos>)
END ELSE
	HazeAvgAvg = RRCIRec<REACT_RUN_CI_SS_HAZE_AVG_AVG$>
END

LOCATE REACT_RUN_CI_SPOTS$ IN DictInfo<FIELDS_FIELD_NO$> SETTING Pos THEN
	Spots = OCONV(RRCIRec<REACT_RUN_CI_SPOTS$>,DictInfo<FIELDS_CONV$,Pos>)
END ELSE
	Spots = RRCIRec<REACT_RUN_CI_SPOTS$>
END

LOCATE REACT_RUN_CI_FOV$ IN DictInfo<FIELDS_FIELD_NO$> SETTING Pos THEN
	FOV	= OCONV(RRCIRec<REACT_RUN_CI_FOV$>,DictInfo<FIELDS_CONV$,Pos>)
END ELSE
	FOV = RRCIRec<REACT_RUN_CI_FOV$>
END

LOCATE REACT_RUN_CI_SCRATCHES$ IN DictInfo<FIELDS_FIELD_NO$> SETTING Pos THEN
	Scratches = OCONV(RRCIRec<REACT_RUN_CI_SCRATCHES$>,DictInfo<FIELDS_CONV$,Pos>)
END ELSE
	Scratches = RRCIRec<REACT_RUN_CI_SCRATCHES$>
END

LOCATE REACT_RUN_CI_SCRATCH_LEN$ IN DictInfo<FIELDS_FIELD_NO$> SETTING Pos THEN
	ScratchLen = OCONV(RRCIRec<REACT_RUN_CI_SCRATCH_LEN$>,DictInfo<FIELDS_CONV$,Pos>)
END ELSE
	ScratchLen = RRCIRec<REACT_RUN_CI_SCRATCH_LEN$>
END


LOCATE REACT_RUN_CI_SS_SCRATCH_MAX$ IN DictInfo<FIELDS_FIELD_NO$> SETTING Pos THEN
	SSScratchMax = OCONV(RRCIRec<REACT_RUN_CI_SS_SCRATCH_MAX$>,DictInfo<FIELDS_CONV$,Pos>)
END ELSE
	SSScratchMax = RRCIRec<REACT_RUN_CI_SS_SCRATCH_MAX$>
END

LOCATE REACT_RUN_CI_SS_SCRATCH_AVG$ IN DictInfo<FIELDS_FIELD_NO$> SETTING Pos THEN
	SSScratchAvg = OCONV(RRCIRec<REACT_RUN_CI_SS_SCRATCH_AVG$>,DictInfo<FIELDS_CONV$,Pos>)
END ELSE
	SSScratchAvg = RRCIRec<REACT_RUN_CI_SS_SCRATCH_AVG$>
END


DataLine  = QUOTE(ReactNo):TAB$
DataLine := QUOTE(RDSNo):TAB$
DataLine := QUOTE(Stage):TAB$
DataLine := QUOTE(ScanTool):TAB$
DataLine := QUOTE(SumOfDefMin):TAB$
DataLine := QUOTE(SumOfDefMax):TAB$
DataLine := QUOTE(SumOfDefAvg):TAB$
DataLine := QUOTE(HazeAvgAvg):TAB$
DataLine := QUOTE(Spots):TAB$
DataLine := QUOTE(FOV):TAB$
DataLine := QUOTE(Scratches):TAB$
DataLine := QUOTE(ScratchLen):TAB$
DataLine := QUOTE(UserName):TAB$
DataLine := QUOTE(SSScratchAvg):TAB$
DataLine := QUOTE(SSScratchMax):TAB$
DataLine := QUOTE(WaferSize)

DOSFile = Environment_Services('GetSPCDataPath') : '\SPC_Surf.txt'

* * * * * * *
DosRead:
* * * * * * *

Set_Status(0)

OSRead DOSRecord FROM DOSFile ELSE
	ErrCode = Status()
	IF ErrCode = 4 THEN
		DOSRecord = ''	;* File doesn't exist
	END ELSE
		ErrMsg('Unable to read DOS file "SPC_Data.TXT" for update. ':ErrCode:' Please try again.')
		RETURN
	END
END
 
DOSRecord := DataLine:CRLF$

OSWrite DOSRecord ON DOSFile

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

RRCIRec<REACT_RUN_CI_SPC_DTM$> = ICONV(CurrDTM,'DT')

RRParms = FieldStore(RRParms,@RM,4,1,RRCIRec)
obj_Tables('WriteRec',RRParms)

RETURN 









