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

/*
	Commuter module for CLEAN_INSP (Clean & Inspection) window
	
	08/5/2009 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Send_Event, Set_Status, Center_Window, Post_Event
DECLARE SUBROUTINE ErrMsg, Send_Message, Set_Property, Send_Event, Btree.Extract, obj_AppWindow, 
DECLARE SUBROUTINE obj_Notes, Security_Err_Msg, End_Window, Forward_Event, Start_Window, Create_Note

DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Utility, Popup, Collect.Ixvals
DECLARE FUNCTION Send_Message, Msg, Security_Check, obj_React_Run_CI, Environment_Services



$INSERT MSG_EQUATES
$INSERT APPCOLORS
$INSERT LSL_USERS_EQU
$INSERT SECURITY_RIGHTS_EQU
$INSERT REACT_EVENT_EQUATES
$INSERT POPUP_EQUATES

EQU CRLF$	TO \0D0A\
EQU TAB$	TO \09\


ErrTitle = 'Error in Comm_Clean_Insp'
ErrorMsg = ''

Result = ''


BEGIN CASE
	CASE EntID = @WINDOW
		BEGIN CASE
			CASE Event = 'CLEAR'			; GOSUB Clear
			CASE Event = 'CREATE' 			; GOSUB Create
			CASE Event = 'CLOSE'			; GOSUB Close
			CASE Event = 'READ'				; GOSUB Read
			CASE Event[1,3] = 'QBF'			; GOSUB Refresh
		END CASE
		
	CASE EntID = 'CLEAN_INSP.SEND_SPC' AND Event = 'CLICK' 	; GOSUB SendSPC
	
		
	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:
* * * * * * *

/*
IF NOT(Security_Check('Reactor Event Log',READ$)) THEN
	Security_Err_Msg('Reactor Event Log',READ$)
	End_Window(@WINDOW)
	RETURN
END
*/

obj_Appwindow('Create',@WINDOW)


IF @USERNAME = 'BRYCE_BARB' OR @USERNAME = 'CHAD_B' THEN
	Set_Property(@WINDOW:'.SEND_SPC','VISIBLE',1)
	Set_Property(@WINDOW:'.SPC_DTM','VISIBLE',1)
END ELSE
	Set_Property(@WINDOW:'.SEND_SPC','VISIBLE',0)
	Set_Property(@WINDOW:'.SPC_DTM','VISIBLE',0)
END



* Provides compatibility with the existing messaging attachment system

IF Parm1 NE '' THEN
	PassedKeys = FIELD(Parm1,'*',1)
	obj_Appwindow('ViewRelated',@WINDOW:@RM:PassedKeys)
END

*IOOptions = Get_Property(@WINDOW,'IOOPTIONS')
*IOOptions<11> = 1	;* Generate READ event on QBFLoad

*Set_Property(@WINDOW,'IOOPTIONS',IOOptions)






GOSUB Refresh

RETURN


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


IF Get_Property(@WINDOW,'@READONLY') THEN
	obj_AppWindow('ReadOnly',@RM:1)			;* Reenables data bound controls
	Set_Property(@WINDOW,'@READONLY',0)		;* Clear flag on window
END


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

Stage		= Get_Property(@WINDOW:'.STAGE','TEXT')
SpecFwiLwi	= Get_Property(@WINDOW:'.SPEC_FWI_LWI','TEXT')

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

Ctrls  = @WINDOW:'.SPEC_CLEAN_SUBOXIDE':@RM				; Props  = 'CHECK':@RM
Ctrls := @WINDOW:'.SPEC_CLEAN_OXIDE_ANGSTROMS':@RM		; Props := 'TEXT':@RM
Ctrls := @WINDOW:'.SPEC_CLEAN_TOOL':@RM					; Props := 'TEXT':@RM
Ctrls := @WINDOW:'.SPEC_CLEAN_AKRION_RECIPE':@RM		; Props := 'TEXT':@RM
Ctrls := @WINDOW:'.SPEC_BRIGHTLIGHT':@RM				; Props := 'CHECK':@RM
Ctrls := @WINDOW:'.SPEC_MICROSCOPE':@RM					; Props := 'CHECK':@RM
Ctrls := @WINDOW:'.SPEC_SURFSCAN':@RM					; Props := 'CHECK':@RM
Ctrls := @WINDOW:'.SPEC_SURFSCAN_RECIPE'				; Props := 'TEXT'

Vals = Get_Property(Ctrls,Props)

SCSubOxide		= Vals[1,@RM]
SCAngstroms		= Vals[COL2()+1,@RM]
SCTool			= Vals[COL2()+1,@RM]
SCAkrionRecipe	= Vals[COL2()+1,@RM] 
SBrightLight	= Vals[COL2()+1,@RM]
SMicroscope		= Vals[COL2()+1,@RM]
SSurfscan		= Vals[COL2()+1,@RM]
SSurfscanRecipe	= Vals[COL2()+1,@RM]

IF SCTool = 'No' THEN SCTool = ''

DefBack = Get_Property(@WINDOW,'BACKCOLOR')

IF SCSubOxide OR SCAngstroms OR SCTool OR SCAkrionRecipe	THEN
	Vals  = 1:@RM:1:@RM:STR(VL_GREEN$:@RM,5)
END ELSE
	Vals  = 0:@RM:0:@RM:STR(DefBack:@RM,5)
END

IF SBrightLight OR SMicroscope THEN
	Vals := 1:@RM:1:@RM:STR(VL_GREEN$:@RM,29)
END ELSE
	Vals := 0:@RM:0:@RM:STR(DefBack:@RM,29)
END
  
IF SSurfscan OR SSurfscanRecipe	THEN
	Vals := 1:@RM:1:@RM:STR(VL_GREEN$:@RM,14)
END ELSE
	Vals := 0:@RM:0:@RM:STR(DefBack:@RM,14)
END

IF Vals[-1,1] = @RM THEN Vals[-1,1] = ''

Ctrls  = @WINDOW:'.CLEANS_GROUP':@RM					; Props  = 'ENABLED':@RM
Ctrls := @WINDOW:'.CLEAN_RESULTS_GROUP':@RM				; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.CLEANS_GROUP':@RM					; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.CLEAN_RESULTS_GROUP':@RM				; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.SPEC_CLEAN_SUBOXIDE':@RM				; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.CLEAN_TOOL_LABEL':@RM				; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.SPEC_CLEAN_AKRION_RECIPE_LABEL':@RM	; Props := 'BACKCOLOR':@RM
		
Ctrls := @WINDOW:'.SURF_INSP_GROUP':@RM					; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.INSP_RESULT_GROUP':@RM				; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.SURF_INSP_GROUP':@RM					; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.INSP_RESULT_GROUP':@RM				; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.SPEC_BRIGHTLIGHT':@RM				; Props := 'BACKCOLOR':@RM		
Ctrls := @WINDOW:'.SPEC_MICROSCOPE':@RM					; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.LPD_IN_LABEL':@RM					; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.LPD_OUT_LABEL':@RM					; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.SPEC_MICROSCOPE':@RM					; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.LPD_LABEL':@RM						; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.LPD_SPEC_LABEL':@RM					; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.PITS_LABEL':@RM						; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.PITS_SPEC_LABEL':@RM					; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.MOUNDS_LABEL':@RM					; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.MOUNDS_SPEC_LABEL':@RM				; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.BL_DEF_LABEL':@RM					; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.BL_DEF_SPEC_LABEL':@RM				; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.STACK_FAULTS_LABEL':@RM				; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.STACK_FAULT_SPEC_LABEL':@RM			; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.SPIKES_LABEL':@RM					; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.SPIKE_SPEC_LABEL':@RM				; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.LONGEST_LABEL':@RM					; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.NOT_TO_EXCEED_LABEL':@RM				; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.SPOTS_LABEL':@RM						; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.FOV_LONG_LABEL':@RM					; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.SPOTS_SPEC_LABEL':@RM				; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.FOV_SPEC_LABEL':@RM					; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.SCRATCH_LABEL':@RM					; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.INCH_LABEL':@RM						; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.SCRATCHES_SPEC_LABEL':@RM			; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.INCH_SPEC_LABEL':@RM					; Props := 'BACKCOLOR':@RM					

Ctrls := @WINDOW:'.SURF_SCAN_GROUP':@RM					; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.SCAN_RESULT_GROUP':@RM				; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.SURF_SCAN_GROUP':@RM					; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.SCAN_RESULT_GROUP':@RM				; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.SPEC_SURFSCAN':@RM					; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.SPEC_SURFSCAN_RECIPE_LABEL':@RM		; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.SAMP_QTY_LABEL':@RM					; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.SS_SCAN_TOOL_LABEL':@RM				; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.SS_SCAN_DTM_LABEL':@RM				; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.SUM_OF_DEFECTS_LABEL':@RM			; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.HAZE_AVG_PPM_LABEL':@RM				; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.SS_SCRATCH_AVG_LABEL':@RM			; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.SPEC_LABEL':@RM						; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.MIN_LABEL':@RM						; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.MAX_LABEL':@RM						; Props := 'BACKCOLOR':@RM
Ctrls := @WINDOW:'.AVG_LABEL'							; Props := 'BACKCOLOR'


Set_Property(Ctrls,Props,Vals)


IF Get_Property(@WINDOW:'.SPC_DTM','DEFPROP') = '' THEN
	Set_Property(@WINDOW:'.SEND_SPC','TEXT','Send to SPC')
END ELSE
	Set_Property(@WINDOW:'.SEND_SPC','TEXT','Resend to SPC')
END

* Check for out of spec on the Surface Scan results

Ctrls  = @WINDOW:'.SUM_OF_DEFECTS_SPEC':@RM			; Props  = 'TEXT':@RM
Ctrls := @WINDOW:'.HAZE_AVG_SPEC':@RM				; Props := 'TEXT':@RM
Ctrls := @WINDOW:'.SUM_OF_DEF_AVG':@RM				; Props := 'TEXT':@RM
Ctrls := @WINDOW:'.SUM_OF_DEF_MAX':@RM				; Props := 'TEXT':@RM
Ctrls := @WINDOW:'.HAZE_AVG_AVG'					; Props := 'TEXT'

Vals = Get_Property(Ctrls,Props)

SumOfDefectsSpec	= Vals[1,@RM]
HazeAvgSpec			= Vals[COL2()+1,@RM]
SumOfDefectsAvg		= Vals[COL2()+1,@RM]
SumOfDefectsMax		= Vals[COL2()+1,@RM]
HazeAvgAvg			= Vals[COL2()+1,@RM]

OutOfSpec = ''
IF SumOfDefectsSpec NE '' THEN
	IF SumOfDefectsMax GE SumOfDefectsSpec THEN
		OutOfSpec = 1
		Set_Property(@WINDOW:'.SUM_OF_DEF_MAX','BACKCOLOR',RED$)
	END
	IF SumOfDefectsAvg GE SumOfDefectsSpec THEN
		OutOfSpec = 1
		Set_Property(@WINDOW:'.SUM_OF_DEF_AVG','BACKCOLOR',RED$)
	END
	
END

IF HazeAvgSpec NE '' THEN
	IF HazeAvgAvg GE HazeAvgSpec THEN
		OutOfSpec = 1
		Set_Property(@WINDOW:'.HAZE_AVG_SPEC','BACKCOLOR',RED$)
	END
END

IF OutOfSpec THEN
	Set_Property(@WINDOW:'.OUT_OF_SPEC','VISIBLE',1)
END ELSE
	Set_Property(@WINDOW:'.OUT_OF_SPEC','VISIBLE',0)
	Set_Property(@WINDOW:'.SUM_OF_DEF_MAX','BACKCOLOR',WHITE$)
	Set_Property(@WINDOW:'.SUM_OF_DEF_AVG','BACKCOLOR',WHITE$)
	Set_Property(@WINDOW:'.HAZE_AVG_AVG','BACKCOLOR',WHITE$)
END

* QBF buttons

Ctrls  = @WINDOW:'.QBF_FIRST_FIX':@RM		; Props  = 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_PREV_FIX':@RM		; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_ABS_FIX':@RM			; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_NEXT_FIX':@RM		; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_LAST_FIX':@RM		; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_STOP_FIX'			; Props := 'ENABLED'

IF Get_Property(@WINDOW,'QBFLIST') = '' THEN
	Vals = 0:@RM:0:@RM:0:@RM:0:@RM:0:@RM:0
END ELSE
	Vals = 1:@RM:1:@RM:1:@RM:1:@RM:1:@RM:1
END

Set_Property(Ctrls,Props,Vals)

* 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>
	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 I
NEXT I

RETURN





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


GOSUB Refresh

RETURN


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

/*
OrderNo = Get_Property(@WINDOW:'.ORD_NO','TEXT')

Message = ''
IF RowExists('ORDER',OrderNo) THEN
	IF Get_Property(@WINDOW,'SAVEWARN') THEN
		Message = 'Order No. ':OrderNo:' has been changed.'
	END
END ELSE
	Message = 'New Order ':QUOTE(OrderNo):' entered into system.'
END

IF Message NE '' THEN
   	
	Recipients		= XLATE('NOTIFICATION','ORDER_ENTRY',NOTIFICATION_USER_ID$,'X')
	SentFrom		= @USER4
	Subject			= 'New/Update Order':OrderNo
	AttachWindow	= 'ORDER2'
	AttachKey		= OrderNo   
	SendToGroup		= ''   

	Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
	*obj_Notes('Create',Parms)																				;* Per Request from Customer Service

	IF Get_Status(errCode) THEN
		ErrMsg(errCode)
	END
 
END
/*/

Result = 1

RETURN


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

/*
IF Security_Check('Order',Delete$) THEN
	Result = 1		;* Proceed with delete
END ELSE
	Security_Err_Msg('Order',Delete$)
	Result = 0		;* Stop event chain
END
*/

RETURN


* * * * * * *
LUReactEsc:
* * * * * * * 

IF NOT(ASSIGNED(Parm1)) THEN FocusControl = ''	ELSE FocusControl = Parm1
IF NOT(ASSIGNED(Parm2)) THEN FocusPos = ''		ELSE FocusPos = Parm2

Set_Status(0)

/*

EventKeys = obj_React_Esc('Find')	

IF Get_Status(errCode) THEN ErrMsg(ErrCode)

IF INDEX(EventKeys,@VM,1) THEN
	TypeOver = ''
	TypeOver<PMODE$> = 'K'
	TypeOver<PDISPLAY$> = EventKeys
	EventKeys = Popup(@WINDOW,TypeOver,'REACT_ESC_QUERY')
END

CONVERT @VM TO @FM IN EventKeys

IF INDEX(EventKeys,@FM,1) THEN
	Send_Event(@WINDOW,'QBFINIT')
	Set_Property(@WINDOW,'QBFLIST',EventKeys)
	GOSUB Refresh
	Send_Event(@WINDOW,'QBFIRST')
END ELSE
	obj_Appwindow('LoadFormKeys',@WINDOW:@RM:EventKeys)
END
*/

RETURN




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


*obj_Notes('Inbox',@USER4)	;* Checks for any new messages

obj_Appwindow('DetailReturn',@WINDOW)

RETURN


* * * * * * *
SendSPC:
* * * * * * *

Ctrls  = @WINDOW:'.RDS_NO':@RM			; Props  = 'DEFPROP':@RM
Ctrls := @WINDOW:'.STAGE':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.SS_SCAN_TOOL':@RM	; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.SUM_OF_DEF_MIN':@RM	; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.SUM_OF_DEF_MAX':@RM	; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.SUM_OF_DEF_AVG':@RM	; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.HAZE_AVG_AVG':@RM	; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.SPOTS':@RM			; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.FOV':@RM				; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.SCRATCHES':@RM		; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.SCRATCH_LEN':@RM		; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.REACT_NO':@RM		; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.WAFER_SIZE':@RM		; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.SS_SCRATCH_MAX':@RM	; Props := 'DEFPROP':@RM
Ctrls := @WINDOW:'.SS_SCRATCH_AVG'		; Props := 'DEFPROP'

Vals = Get_Property(Ctrls,Props)

RDSNo			= Vals[1,@RM]
Stage			= Vals[COL2()+1,@RM]
ScanTool		= Vals[COL2()+1,@RM]
SumOfDefMin		= Vals[COL2()+1,@RM]
SumOfDefMax		= Vals[COL2()+1,@RM]
SumOfDefAvg		= Vals[COL2()+1,@RM]
HazeAvgAvg		= Vals[COL2()+1,@RM]
Spots			= Vals[COL2()+1,@RM]
FOV				= Vals[COL2()+1,@RM]
Scratches		= Vals[COL2()+1,@RM]
ScratchLen		= Vals[COL2()+1,@RM]
ReactNo			= Vals[COL2()+1,@RM]
WaferSize		= Vals[COL2()+1,@RM]
SSScratchMax	= Vals[COL2()+1,@RM]
SSScratchAvg	= Vals[COL2()+1,@RM]


WaferSize = WaferSize[1,' ']		;* Data looks like "125 mm 6 in"

UserName = OCONV(@USER4,'[XLATE_CONV,LSL_USERS*FIRST_LAST]')

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)

IF @USERNAME = 'BRYCE_BARB' THEN
	DOSFile = Environment_Services('GetApplicationRootPath') : '\SPC_Surf.TXT'
END ELSE
	*DOSFile = 'R:\SPC_Surf.TXT'
* 	DOSFile = 'N:\IT\CommonRW\OI_SPC_Data_Transfer\SPC_Surf.TXT'
* 	DOSFile = Environment_Services('GetUserDataProductionPath') : '\CommonRW\OI_SPC_Data_Transfer\SPC_Surf.TXT'
    DOSFile = Environment_Services('GetSPCDataProductionPath') : '\SPC_Surf.txt'
END

* * * * * * *
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')

Set_Property(@WINDOW:'.SPC_DTM','DEFPROP',CurrDTM)

RETURN 



* * * * * * *
SetGroupBackground:
* * * * * * *




