COMPILE ROUTINE Test_CustPN(Dummy)
ROWDEF (CHARSTR)

DECLARE SUBROUTINE SEND_INFO, SEND_DYN, Utility, RList, Btree.Extract, msg, ErrMsg
DECLARE FUNCTION obj_Popup, Dialog_Box, obj_Install

OPEN 'PROD_SPEC' TO FileIn ELSE GOTO Bail

$INSERT PROD_SPEC_EQU
$INSERT QUOTE_SPEC_EQU

Select FileIn

Done = 0
LOOP
	READNEXT PSN ELSE Done = 1
UNTIL Done
	
		READ PSNRec FROM FileIn,PSN THEN
			PartNos		= PSNRec<PROD_SPEC_PART_NUMS$>
			SuppliedBy	= PSNRec<PROD_SPEC_SPEC_SUBSTRATE$,QSSubWafersSupBy$>
			ReactorType	= PSNRec<PROD_SPEC_REACTOR_TYPE$>
			CustNo		= PSNRec<PROD_SPEC_CUST_ID$>
			
			
			CustPartNos = ''
			FOR I = 1 TO COUNT(PartNos,@VM) + (PartNos NE '')
				PartNo = PartNos<1,I>
				CustPartNo = ''
				IF  ReactorType NE 'P' THEN
					IF CustNo NE '6880' AND CustNo NE '6766' AND CustNo NE '6795' AND CustNo NE '6799' THEN
						GOSUB MakeCustPN
					END
				END
				
				CustPartNos<1,I> = CustPartNo
			NEXT I
			WRITEV CustPartNos ON FileIn,PSN,PROD_SPEC_CUST_PART_NO$ THEN
				Send_Info(PSN)
			END
		END
	
REPEAT


goto Bail

* * * * * * *
MakeCustPN:
* * * * * * *

CustPartNo = PartNo

CONVERT @LOWER_CASE TO @UPPER_CASE IN CustPartNo


IF CustPartNo[1,6] = 'MATRIX'		THEN CustPartNo = ''

SWAP '1ST LAYER'		WITH '' IN CustPartNo
SWAP '2ND LAYER'		WITH '' IN CustPartNo
SWAP '3RD LAYER'		WITH '' IN CustPartNo
SWAP '1ST & 3RD LAYER'	WITH '' IN CustPartNo
SWAP 'LAYER 1'			WITH '' IN CustPartNo
SWAP 'LAYER 2'			WITH '' IN CustPartNo
SWAP 'LAYER1'			WITH '' IN CustPartNo
SWAP 'LAYER2'			WITH '' IN CustPartNo
SWAP 'MATRIX'			WITH '' IN CustPartNo
SWAP 'MARIX'			WITH '' IN CustPartNo

SWAP 'RED PHOS'			WITH '' IN CustPartNo
SWAP 'HG PROBE'			WITH '' IN CustPartNo
SWAP 'BACKSIDE'			WITH '' IN CustPartNo
SWAP 'TEST WAFERS'		WITH '' IN CustPartNo
SWAP ' - '				WITH '' IN CustPartNo
SWAP 'BORON'			WITH '' IN CustPartNo
SWAP 'ON ORIENTATION'	WITH '' IN CustPartNo
SWAP '6IN'				WITH '' IN CustPartNo


SWAP 'SET-UP'			WITH '' IN CustPartNo
SWAP 'SETUP'			WITH '' IN CustPartNo
SWAP 'W/LTO-HTR'		WITH '' IN CustPartNo
SWAP 'W/LTO'			WITH '' IN CustPartNo
SWAP 'W/LTO-DUAL'		WITH '' IN CustPartNo
SWAP 'ENGINEERING'		WITH '' IN CustPartNo
SWAP 'MOD'				WITH '' IN CustPartNo
SWAP '.' 				WITH '' IN CustPartNo
SWAP 'DSP'				WITH '' IN CustPartNo
SWAP 'SEE NOTES'		WITH '' IN CustPartNo
SWAP 'ENG LOT'			WITH '' IN CustPartNo
SWAP 'DUAL'				WITH '' IN CustPartNo

SWAP 'LAYERS 1 & 2 OF' WITH '' IN CustPartNo

IF INDEX(CustPartNo,'SUBSTRATE',1)	THEN CustPartNo = ''
IF INDEX(CustPartNo,'EPIPRO',1)		THEN CustPartNo = ''
IF INDEX(CustPartNo,'TRENCH',1)		THEN CustPartNo = ''
IF INDEX(CustPartNo,'LIKE',1)		THEN CustPartNo = ''
IF INDEX(CustPartNo,'BASED',1)		THEN CustPartNo = ''
IF INDEX(CustPartNo,'WAFERS',1)		THEN CustPartNo = ''
IF INDEX(CustPartNo,'QUARTZ',1)		THEN CustPartNo = ''
IF INDEX(CustPartNo,'RESHEATH',1)	THEN CustPartNo = ''
IF INDEX(CustPartNo,'ETCH',1)		THEN CustPartNo = ''

IF CustPartNo = 'HELITEK/WAFERWORKS' THEN CustPartNo = ''
IF CustPartNo = 'SUBS' THEN CustPartNo = ''
IF CustPartNo = 'DO NOT USE' THEN CustPartNo = ''

*IF CustPartNo[1,3] MATCHES '1N"UM"'	THEN CustPartNo = ''
*IF CustPartNo[1,4] MATCHES '2N"UM"'	THEN CustPartNo = ''
IF CustPartNo[1,6] MATCHES '3 OF 3' THEN CustPartNo = ''
IF CustPartNo[1,4] = 'SIC,' 		THEN CustPartNo = ''
IF CustPartNo[1,6] = '4H SIC' 		THEN CustPartNo = ''
IF CustPartNo[1,6] = 'MATRIX'		THEN CustPartNo = ''
IF CustPartNo = 'ISONICS'			THEN CustPartNo = ''
IF CustPartNo = '20V 37UM'			THEN CustPartNo = ''
IF CustPartNo = 'HTR'				THEN CustPartNo = ''
IF CustPartNo[1,5] = 'N 20V'		THEN CustPartNo = ''
IF CustPartNo[1,5] = 'N 60V'		THEN CustPartNo = ''
IF CustPartNo[1,9] = 'NTYPE 30V'	THEN CustPartNo = ''
IF CustPartNo = 'ASSUBS'			THEN CustPartNo = ''
IF CustPartNo[1,5] = 'N-30V'		THEN CustPartNo = ''
IF CustPartNo = '605UM'				THEN CustPartNo = ''
IF CustPartNo = 'CDP003G (P30V)'	THEN CustPartNo = ''


IF CustPartNo[1,6] = '535744' 		THEN CustPartNo = '535744'
IF CustPartNo[1,6] = '548513' 		THEN CustPartNo = '548513'
IF CustPartNo[1,6] = '400116' 		THEN CustPartNo = '400116'
IF CustPartNo[1,6] = '400127' 		THEN CustPartNo = '400127'
IF CustPartNo[1,6] = '400138' 		THEN CustPartNo = '400138'
IF CustPartNo[1,6] = '400149' 		THEN CustPartNo = '400149'
IF CustPartNo[1,6] = '400150' 		THEN CustPartNo = '400150'
IF CustPartNo[1,6] = '491688' 		THEN CustPartNo = '491688'
IF CustPartNo[1,6] = '529792' 		THEN CustPartNo = '529792'
IF CustPartNo[1,6] = '539872' 		THEN CustPartNo = '539872'
IF CustPartNo[1,6] = '546375' 		THEN CustPartNo = '546375'
IF CustPartNo[1,6] = '563352' 		THEN CustPartNo = '563352'
IF CustPartNo[1,6] = '582038' 		THEN CustPartNo = '582038'
IF CustPartNo[1,6] = '594446' 		THEN CustPartNo = '594446'
IF CustPartNo[1,6] = '604370' 		THEN CustPartNo = '604370'
IF CustPartNo[1,6] = '608071' 		THEN CustPartNo = '608071'
IF CustPartNo[1,6] = '626543' 		THEN CustPartNo = '626543'
IF CustPartNo[1,6] = '646354' 		THEN CustPartNo = '646354'
IF CustPartNo[1,6] = '707633' 		THEN CustPartNo = '707633'
IF CustPartNo[1,6] = '687281' 		THEN CustPartNo = '687281'
IF CustPartNo[1,6] = '737872' 		THEN CustPartNo = '737872'
IF CustPartNo[1,6] = '737883' 		THEN CustPartNo = '737883'



IF CustPartNo[1,8] = '09377640'		THEN CustPartNo = '09377640'

IF CustPartNo[1,1] ='-'		THEN CustPartNo[1,1] = ''
IF CustPartNo[-1,1] = '-'	THEN CustPartNo[-1,1] = ''

CONVERT ' ' TO @VM IN CustPartNo

FOR W = 1 TO COUNT(CustPartNo,@VM) + (CustPartNo NE '')
	Word = CustPartNo<1,W>
	IF Word[1,5] MATCHES '1A4N' OR Word MATCHES '1A"#"4N' THEN
		IF Word[1,1] = 'Q' THEN
			CustPartNo = ''
		END
	END
UNTIL CustPartNo = ''
NEXT W

CONVERT @VM TO ' ' IN CustPartNo

CustPartNo = TRIM(CustPartNo)


RETURN


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

END
