COMPILE ROUTINE FIX_EPI_PART(Dummy)
ROWDEF (CHARSTR)


DECLARE SUBROUTINE SEND_INFO, SEND_DYN, RList,Btree.Extract, Set_Status, Get_Status
DECLARE FUNCTION obj_Epi_Part


$INSERT EPI_PART_EQUATES
$INSERT PART_EQUATES
$INSERT PROD_SPEC_EQUATES

EQU TAB$ TO CHAR(09)


OPEN 'EPI_PART' TO EpiPartTable ELSE
	DEBUG
	GOTO Bail
END

OPEN 'PROD_SPEC' TO PSTable ELSE
	DEBUG
	GOTO Bail
END

OPEN 'DICT.EPI_PART' TO @DICT ELSE
	DEBUG
	GOTO Bail
END


SELECT EpiPartTable

DebugFlag = 0
RecCnt = 0
Done = 0
LOOP
	READNEXT EpiPartNo ELSE Done = 1
UNTIL Done

	READ EpiPartRec FROM EpiPartTable,EpiPartNo THEN
	
		@RECORD = EpiPartRec
		@ID = EpiPartNo
	
		IF EpiPartNo = '854164' THEN DebugFlag = 1
		*IF DebugFlag THEN DEBUG
		
		Steps = EpiPartRec<EPI_PART_EPI_STEP$>
	
		IF Steps NE '' THEN
			StepCnt = COUNT(Steps,@VM) + (Steps NE '')
			
			FOR I = 1 TO StepCnt
				Step = Steps<1,I>
				IF NOT(NUM(Step)) THEN
					Send_Dyn(EpiPartNo:TAB$:QUOTE(Step))
				END
			NEXT I
			IF DebugFlag THEN
				Send_Dyn('*** ':EpiPartNo:TAB$:{EPI_STEP})
			END ELSE
				Send_Dyn(EpiPartNo:TAB$:EpiPartRec<EPI_PART_EPI_STEP$>)
			END
		END
	
	END	;* End of record read
		
REPEAT

GOTO Bail




SELECT EpiPartTable

RecCnt = 0
Done = 0
LOOP
	READNEXT EpiPartNo ELSE Done = 1
UNTIL Done

	READ EpiPartRec FROM EpiPartTable,EpiPartNo THEN
		RecCnt += 1
		
		PartDesc = EpiPartRec<EPI_PART_EPI_PART_DESC$>
		
		IF INDEX(PartDesc,'|',1) THEN
			OrgDesc = PartDesc
			CONVERT '|' TO '/' IN PartDesc
			EpiPartRec<EPI_PART_EPI_PART_DESC$> = PartDesc
		
			WRITE EpiPartRec ON  EpiPartTable,EpiPartNo THEN
				Send_Dyn(RecCnt:EpiPartNo:' ':OrgDesc:' -> ':PartDesc)
			END
		END
	END
		
REPEAT

GOTO Bail

SELECT EpiPartTable

RecCnt = 0
Done = 0
LOOP
	READNEXT EpiPartNo ELSE Done = 1
UNTIL Done

	
	AllPSNos = XLATE('EPI_PART',EpiPartNo,'ALL_PS_NOS','X')
	
	PSCnt = COUNT(AllPSNos,@VM) + (AllPSNos NE '')
	
	FOR I = 1 TO PSCnt
		PSNo = AllPSNos<1,I>
	
		
		READ PSRec FROM PSTable,PSNo THEN
			LOCATE EpiPartNo in PSRec<PROD_SPEC_EPI_PART_NO$> USING @VM SETTING Pos ELSE
				PSRec = INSERT(PSRec,PROD_SPEC_EPI_PART_NO$,Pos,0,EpiPartNo)
				WRITE PSRec ON PSTable,PSNo THEN
					Send_Dyn(RecCnt:' PS: ':PSNo:' ':PSRec<PROD_SPEC_EPI_PART_NO$>)
				END
			END
		END
		RecCnt += 1
		
		Send_Info(RecCnt:' PS: ':PSNo:' ':EpiPartNo)
	NEXT I	
		
REPEAT

GOTO Bail

SELECT EpiPartTable

RecCnt = 0
Done = 0
LOOP
	READNEXT EpiPartNo ELSE Done = 1
UNTIL Done
	
	READ EpiPartRec FROM EpiPartTable,EpiPartNo THEN
		RecCnt += 1
		
		Send_Info(RecCnt)
		
		SpecData = obj_Epi_Part('GetLayers',EpiPartNo:@RM:EpiPartRec)
		
		IF SpecData NE @FM:@FM:@FM:@FM:@FM:@FM:@FM THEN
			OrgPartRec = EpiPartRec
			
			EpiPartRec<EPI_PART_EPI_LAYER$>		= SpecData[1,@FM]
			EpiPartRec<EPI_PART_EPI_STEP$>		= SpecData[COL2()+1,@FM]
			EpiPartRec<EPI_PART_EPI_STEP_LSID$>	= SpecData[COL2()+1,@FM]
			EpiPartRec<EPI_PART_EPI_DOPANT$>	= SpecData[COL2()+1,@FM]
			EpiPartRec<EPI_PART_EPI_THICK_MIN$>	= SpecData[COL2()+1,@FM]
			EpiPartRec<EPI_PART_EPI_THICK_MAX$>	= SpecData[COL2()+1,@FM]
			EpiPartRec<EPI_PART_EPI_RES_MIN$>	= SpecData[COL2()+1,@FM]
			EpiPartRec<EPI_PART_EPI_RES_MAX$>	= SpecData[COL2()+1,@FM]
			
			IF EpiPartRec NE OrgPartRec THEN
				WRITE EpiPartRec ON EpiPartTable,EpiPartNo THEN
					Send_Dyn(EpiPartNo)
				END
			END
		END
		
	END
REPEAT

GOTO Bail


* * * * * * *
Bail:
* * * * * * *

END



/*





RecCnt = 0
Done = 0
LOOP
	READNEXT EpiPartNo ELSE Done = 1
UNTIL Done
	
	READ EpiPartRec FROM EpiPartTable,EpiPartNo THEN
		RecCnt += 1
		
		Send_Info(RecCnt)
		
		PartNos = EpiPartRec<EPI_PART_PART_NO$>
		
		IF PartNos NE '' THEN
		
			CustPartDescs = XLATE('PART',PartNos,PART_CUST_PART_DESC$,'X')
			
			OrgPartDescs = CustPartDescs
			
			CONVERT @LOWER_CASE TO @UPPER_CASE IN CustPartDescs
			
			SWAP 'ASM+' 		WITH '' IN CustPartDescs
			SWAP 'ASM' 			WITH '' IN CustPartDescs
			SWAP 'HTR' 			WITH '' IN CustPartDescs
			SWAP '-' 			WITH '' IN CustPartDescs
			SWAP 'IRCLEAN' 		WITH '' IN CustPartDescs
			SWAP 'IRCLEA' 		WITH '' IN CustPartDescs
			SWAP 'NOCLEAN'		WITH '' IN CustPartDescs
			SWAP 'LCNOCL'		WITH '' IN CustPartDescs
			SWAP 'R1C' 			WITH '' IN CustPartDescs
			SWAP 'GEN10.7 '		WITH '' IN CustPartDescs
			SWAP 'GEN 10.5 '	WITH '' IN CustPartDescs
			SWAP 'G12.2 '		WITH '' IN CustPartDescs
			SWAP 'TARGET '		WITH '' IN CustPartDescs
		
		
			IF CustPartDescs NE '' THEN
				DescCnt = COUNT(CustPartDescs,@VM) + (CustPartDescs NE '')
				EpiPartDesc = ''
				FOR I = 1 TO DescCnt
					CustPartDesc = TRIM(CustPartDescs<1,I>)
					IF CustPartDesc NE '' THEN
						LOCATE CustPartDesc IN EpiPartDesc USING @FM SETTING Pos ELSE
							EpiPartDesc = INSERT(EpiPartDesc,Pos,0,0,CustPartDesc)
						END
					END ;* Check for null CustPartDesc
				NEXT I
			
				CONVERT @FM TO '|' IN EpiPartDesc
				
				EpiPartRec<EPI_PART_EPI_PART_DESC$> = EpiPartDesc
					
				WRITE EpiPartRec ON EpiPartTable,EpiPartNo THEN
					Send_Dyn('EpiPart ':EpiPartNo:' - ':EpiPartDesc)
				END
				
			END
			
		END	;* End of check for PartNos		
	END
REPEAT

GOTO Bail

*/
