COMPILE Subroutine MOVE_RDS_DICT(Dummy)
* ROWDEF(CHARSTR)

DECLARE SUBROUTINE obj_Schedule,Send_Dyn,Send_Info, Send_Dyn, obj_WO_Step, Set_Status, RList, obj_RDS_Layer
DECLARE FUNCTION Get_Status, Set_Printer, obj_RDS, NextKey, obj_Prod_Spec, obj_RDS_Test

$INSERT DICT_EQUATES
$INSERT RDS_EQU
$INSERT RDS_LAYER_EQUATES
$INSERT RDS_TEST_EQUATES
$INSERT RDS_LAYER_INFO_EQU
$INSERT PRS_LAYER_EQU
$INSERT RECIPE_EQU
$INSERT RECIPE_LAYER_INFO_EQU


EQU SHEETRHO_SPEC_UNITS$	TO \EA2FDC\
EQU RES_SPEC_UNITS$			TO \EA2D636D\


OPEN 'RDS' TO RDSTable ELSE
	DEBUG
	GOTO Bail
END

OPEN 'RDS_LAYER' TO RDSLayerTable ELSE
	DEBUG
	GOTO Bail
END

OPEN 'RDS_TEST' TO RDSTestTable ELSE
	DEBUG
	GOTO Bail
END


OPEN 'DICT.RDS' TO FileIn ELSE
	DEBUG
	GOTO Bail
END

OPEN 'DICT.RDS_LAYER' TO FileOut ELSE
	DEBUG
	GOTO Bail
END

OPEN 'DICT.RDS_TEST' TO DictRDSTest ELSE
	DEBUG
	GOTO Bail
END



IF Get_Status(errCode) THEN DEBUG

* Now do the fields for the RDS_TEST (metrology table)

SelectSent = 'SELECT RDS WITH WO < 130261'

EQU TARGET_ACTIVELIST$ to 5
RList(SelectSent,TARGET_ACTIVELIST$, "", "", "")



RecCnt = 0
Done = 0

LOOP
	READNEXT RDSNo ELSE Done = 1
UNTIL Done

	READ RDSRec FROM RDSTable,RDSNo THEN
		RecCnt += 1
		Send_Info(RecCnt)
		RecLen = LEN(RDSRec)
		IF RecLen > 261 THEN
			PSNId = RDSRec<RDS_PROD_SPEC_ID$>
			RDSLayRec = ''
			LS_ID = 'L1'			;* Always have at least this layer
			
			obj_RDS_Layer('Create',RDSNo:@RM:LS_ID:@RM:PSNId)  	;* Creates record and load recipe limits in it
			
			READ RDSLayerRec FROM RDSLayerTable,RDSNO:'*':LS_ID THEN
				RDSLayerRec<RDS_LAYER_RECIPE_NO$>			= RDSRec<RDS_RECIPE_NO$>
				RDSLayerRec<RDS_LAYER_EPI_TIME$>			= RDSRec<RDS_EPI_TIME$>
				RDSLayerRec<RDS_LAYER_DILUENT_ADJ_PARAM$>	= RDSRec<RDS_DILUENT_ADJ_PARAM$>
				RDSLayerRec<RDS_LAYER_DOPANT_FLOW$>			= RDSRec<RDS_DOPANT_FLOW$>
				RDSLayerRec<RDS_LAYER_HCL_FLOW$>			= RDSRec<RDS_HCL_FLOW$>
				RDSLayerRec<RDS_LAYER_BAKE_TIME$>			= RDSRec<RDS_BAKE_TIME$>
				RDSLayerRec<RDS_LAYER_EPI_H2_FLOW$>			= RDSRec<RDS_EPI_H2_FLOW$>
				RDSLayerRec<RDS_LAYER_TCS_FLOW$>			= RDSRec<RDS_TCS_FLOW$>
				RDSLayerRec<RDS_LAYER_DCS_FLOW$>			= RDSRec<RDS_DCS_FLOW$>
				RDSLayerRec<RDS_LAYER_AUX1$>				= RDSRec<RDS_AUX1$>
				RDSLayerRec<RDS_LAYER_AUX2$>				= RDSRec<RDS_AUX2$>
				RDSLayerRec<RDS_LAYER_F_OFFSET$>			= RDSRec<RDS_F_OFFSET$>
				RDSLayerRec<RDS_LAYER_S_OFFSET$>			= RDSRec<RDS_S_OFFSET$>
				RDSLayerRec<RDS_LAYER_R_OFFSET$>			= RDSRec<RDS_R_OFFSET$>
				RDSLayerRec<RDS_LAYER_ETCH1$>				= RDSRec<RDS_ETCH1$>
				RDSLayerRec<RDS_LAYER_ETCH2$>				= RDSRec<RDS_ETCH2$>
				RDSLayerRec<RDS_LAYER_ETCH3$>				= RDSRec<RDS_ETCH3$>
				RDSLayerRec<RDS_LAYER_UL_TEMP$>			    = RDSRec<RDS_UL_TEMP$>

				WRITE RDSLayerRec ON RDSLayerTable,RDSNO:'*':LS_ID ELSE NULL
			END
			
			WaferSize		= XLATE( 'PROD_SPEC', PSNId, 'SUB_WAFER_SIZE', 'X' )
			SubOrientation	= XLATE('PROD_SPEC',PSNId,'SUB_ORIENTATION','X')
			ResUnits		= RDSRec<RDS_RES_UNITS$>
			
			RDSTestRec = ''
			RDSTestRec<RDS_TEST_RDS_NO$> = RDSNo
			RDSTestRec<RDS_TEST_LS_ID$> = 'L1'
			RDSTestRec<RDS_TEST_WAFER_SIZE$>			= WaferSize
			RDSTestRec<RDS_TEST_SUB_ORIENTATION$>		= SubOrientation
			
			RDSTestRec<RDS_TEST_SPEC_THICK_MIN$>		= RDSRec<RDS_THICK_MIN$>
			RDSTestRec<RDS_TEST_SPEC_THICK_TARGET$>		= RDSRec<RDS_THICK_TARGET$>
			RDSTestRec<RDS_TEST_SPEC_THICK_MAX$>		= RDSRec<RDS_THICK_MAX$>
			RDSTestRec<RDS_TEST_SPEC_THICK_UNITS$>		= RDSRec<RDS_THICK_UNITS$>
			RDSTestRec<RDS_TEST_SPEC_RES_MIN$>			= RDSRec<RDS_RES_MIN$>
			RDSTestRec<RDS_TEST_SPEC_RES_TARGET$>		= RDSRec<RDS_RES_TARGET$>
			RDSTestRec<RDS_TEST_SPEC_RES_MAX$>			= RDSRec<RDS_RES_MAX$>
			RDSTestRec<RDS_TEST_SPEC_RES_UNITS$>		= RDSRec<RDS_RES_UNITS$>
			RDSTestRec<RDS_TEST_SPEC_CON_MIN$>			= RDSRec<RDS_CON_MIN$>
			RDSTestRec<RDS_TEST_SPEC_CON_TARGET$>		= RDSRec<RDS_CON_TARGET$>
			RDSTestRec<RDS_TEST_SPEC_CON_MAX$>			= RDSRec<RDS_CON_MAX$>
			RDSTestRec<RDS_TEST_SPEC_CON_UNITS$>		= RDSRec<RDS_CON_UNITS$>
			
			RDSTestRec<RDS_TEST_READ_SHEET_RHO$>		= ICONV(OCONV(RDSRec<RDS_SHEETRHO_READ$>,'MD2'),'MD3')
			
			RDSTestRec<RDS_TEST_READ_THICK$>			= RDSRec<RDS_THICK_READ$>
			
			RDSTestRec<RDS_TEST_THICK_AVG$>				= RDSRec<RDS_TTHICK_AVG$>
			RDSTestRec<RDS_TEST_THICK_STDV$>			= RDSRec<RDS_TTHICK_STDEV$>
			RDSTestRec<RDS_TEST_THICK_UNIF$>			= RDSRec<RDS_TTHICK_UNIF$>
			RDSTestRec<RDS_TEST_THICK_MIN$>				= RDSRec<RDS_TTHICK_MIN$>
			RDSTestRec<RDS_TEST_THICK_MAX$>				= RDSRec<RDS_TTHICK_MAX$>
			
			IF ResUnits = SHEETRHO_SPEC_UNITS$ THEN
			
				RDSTestRec<RDS_TEST_SHEETRHO_AVG$>			= RDSRec<RDS_TRES_AVG$>
				RDSTestRec<RDS_TEST_SHEETRHO_STDV$>			= RDSRec<RDS_TRES_STDEV$>
				RDSTestRec<RDS_TEST_SHEETRHO_UNIF$>			= RDSRec<RDS_TRES_UNIF$>
				RDSTestRec<RDS_TEST_SHEETRHO_MIN$>			= RDSRec<RDS_TRES_MIN$>
				RDSTestRec<RDS_TEST_SHEETRHO_MAX$>			= RDSRec<RDS_TRES_MAX$>
				
				RDSTestRec<RDS_TEST_RES_AVG$>				= ''
				RDSTestRec<RDS_TEST_RES_STDV$>				= ''
				RDSTestRec<RDS_TEST_RES_UNIF$>				= ''
				RDSTestRec<RDS_TEST_RES_MIN$>				= ''
				RDSTestRec<RDS_TEST_RES_MAX$>				= ''
			
			END ELSE
			
				RDSTestRec<RDS_TEST_SHEETRHO_AVG$>			= ''
				RDSTestRec<RDS_TEST_SHEETRHO_STDV$>			= ''
				RDSTestRec<RDS_TEST_SHEETRHO_UNIF$>			= ''
				RDSTestRec<RDS_TEST_SHEETRHO_MIN$>			= ''
				RDSTestRec<RDS_TEST_SHEETRHO_MAX$>			= ''
				
				RDSTestRec<RDS_TEST_RES_AVG$>				= RDSRec<RDS_TRES_AVG$>
				RDSTestRec<RDS_TEST_RES_STDV$>				= RDSRec<RDS_TRES_STDEV$>
				RDSTestRec<RDS_TEST_RES_UNIF$>				= RDSRec<RDS_TRES_UNIF$>
				RDSTestRec<RDS_TEST_RES_MIN$>				= RDSRec<RDS_TRES_MIN$>
				RDSTestRec<RDS_TEST_RES_MAX$>				= RDSRec<RDS_TRES_MAX$>
				
			END
			
			RDSTestRec<RDS_TEST_THICK_OVERGROW_AVG$>	= RDSRec<RDS_THICK_OVR_GROWTH_AVG$>
			
			RDSTestRec<RDS_TEST_SRP_PROFILE_PATH$>		= RDSRec<RDS_SRP_PROFILE_PATH$>
						
			* Now load the specification stuff that was not copied in the org system
			
			SpecLayerData	= obj_Prod_Spec('GetLayerProp',PSNId:@RM:LS_ID:@RM:1)	;* Gets 1st layer WO/Conversiion
			SpecLayerID		= SpecLayerData[1,@FM]
			SpecLayerData	= FIELD(SpecLayerData,@FM,2,999)
					
			RDSTestRec<RDS_TEST_SPEC_DOPANT$>		= SpecLayerData<PRS_LAYER_DOPANT$>
			RDSTestRec<RDS_TEST_SPEC_RECIPE$>		= SpecLayerData<PRS_LAYER_RECIPE$>
			RDSTestRec<RDS_TEST_SPEC_RECIPE_NAME$>	= SpecLayerData<PRS_LAYER_RECIPE_NAME$>
			
			
			FOR A = 11 TO 19
				RDSTestRec<A> = SpecLayerData<PRS_LAYER_THICK_MEASUREMENT$,A-10>
			NEXT A
				
			FOR A = 24 TO 32
				RDSTestRec<A> = SpecLayerData<PRS_LAYER_RES_MEASUREMENT$,A-23>
			NEXT A
			
			FOR A = 37 TO 45
				RDSTestRec<A> = SpecLayerData<PRS_LAYER_CONC_MEASUREMENT$,A-36>
			NEXT A
			
			FOR A = 50 to 58
				RDSTestRec<A> = SpecLayerData<PRS_LAYER_STRESS_MEASUREMENT$,A-49>
			NEXT A

			RDSTestRec<RDS_TEST_SPEC_TRANS$>				= SpecLayerData<PRS_LAYER_TRANS_SPEC$>
			RDSTestRec<RDS_TEST_SPEC_TRANS_MEASUREMENT$>	= SpecLayerData<PRS_LAYER_TRANS_MEASUREMENT$>
			
			
			GOSUB LoadTestWafers
			
			RDSTestRec = obj_RDS_Test('CalcMissing',RDSTestRec)
			
			NextTestKey = NextKey('RDS_TEST')
			
			WRITE RDSTestRec ON RDSTestTable,NextTestKey ELSE NULL
			
			
			
			* Check for additional layers shoved down the rabbit hole in field <33>
			
			LayerMess = RDSRec<RDS_LAYER_INFO$>
			
			CONVERT CHAR(248) TO @FM IN LayerMess
			
			LayerCnt = COUNT(LayerMess,@FM) + (LayerMess NE '')
			
			
			
			FOR N= 1 TO LayerCnt
				LayerNo = N + 1
				IF N = LayerCnt THEN
					LS_ID = N
				END ELSE
					LS_ID = 'L':LayerNo
				END
				
				RecipeNo = LayerMess<N,RLRecipeNo$>
				
				IF INDEX(LS_ID,'L',1) THEN
					obj_RDS_Layer('Create',RDSNo:@RM:LS_ID:@RM:PSNId)  	;* Creates record and load recipe limits in it
					READ RDSLayerRec FROM RDSLayerTable,RDSNO:'*':LS_ID ELSE NULL
				END ELSE
					RDSLayerRec = ''
				END
							
				RDSLayerRec<RDS_LAYER_RECIPE_NO$>			= RecipeNo
				
				IF INDEX(LS_ID,'L',1) THEN
					RDSLayerRec<RDS_LAYER_EPI_TIME$>			= LayerMess<N,RLEpiTime$>
					RDSLayerRec<RDS_LAYER_DOPANT_FLOW$>			= LayerMess<N,RLDopantFlow$>
				END
				
				WRITE RDSLayerRec ON RDSLayerTable,RDSNO:'*':LS_ID ELSE NULL
				
				
				PSNLayerData = obj_Prod_Spec('GetLayerProp',PSNId:@RM:LS_ID)
				PSNLayerData = FIELD(PSNLayerData,@FM,2,999)	;* Layer ID is returned in the 1st field position
				 				
				NextTestKey = NextKey('RDS_TEST')
				
				RDSTestRec = ''
				RDSTestRec<RDS_TEST_RDS_NO$>					= RDSNo
				RDSTestRec<RDS_TEST_LS_ID$>						= LS_ID
				RDSTestRec<RDS_TEST_SPEC_THICK_MIN$>			= LayerMess<N,RLThickMin$>
				RDSTestRec<RDS_TEST_SPEC_THICK_TARGET$>			= LayerMess<N,RLThickTarget$>
				RDSTestRec<RDS_TEST_SPEC_THICK_MAX$>			= LayerMess<N,RLThickMax$>
				RDSTestRec<RDS_TEST_SPEC_THICK_UNITS$>			= LayerMess<N,RLThickUnits$>
				
				RDSTestRec<RDS_TEST_SPEC_RES_MIN$>				= LayerMess<N,RLResMin$>
				RDSTestRec<RDS_TEST_SPEC_RES_TARGET$>			= LayerMess<N,RLResTarget$>
				RDSTestRec<RDS_TEST_SPEC_RES_MAX$>				= LayerMess<N,RLResMax$>
				RDSTestRec<RDS_TEST_SPEC_RES_UNITS$>			= LayerMess<N,RLResUnits$>
				
				RDSTestRec<RDS_TEST_SPEC_CON_MIN$>				= LayerMess<N,RLConMin$>
				RDSTestRec<RDS_TEST_SPEC_CON_TARGET$>			= LayerMess<N,RLConTarget$>
				RDSTestRec<RDS_TEST_SPEC_CON_MAX$>				= LayerMess<N,RLConMax$>
				RDSTestRec<RDS_TEST_SPEC_CON_UNITS$>			= LayerMess<N,RLConUnits$>
				
				RDSTestRec<RDS_TEST_SPEC_STRESS_MIN$>			= PSNLayerData<PRS_LAYER_STRESS_MIN$>
				RDSTestRec<RDS_TEST_SPEC_STRESS_MAX$>			= PSNLayerData<PRS_LAYER_STRESS_MAX$>
				
				RDSTestRec<RDS_TEST_SPEC_TRANS$>				= PSNLayerData<PRS_LAYER_TRANS_SPEC$>
				RDSTestRec<RDS_TEST_SPEC_TRANS_MEASUREMENT$>	= PSNLayerData<PRS_LAYER_TRANS_MEASUREMENT$>
				
				RDSTestRec<RDS_TEST_WAFER_SIZE$>				= WaferSize
				RDSTestRec<RDS_TEST_SUB_ORIENTATION$>			= SubOrientation
				
				SheetRHOReads  = LayerMess<N,RLSheetRHORead$>
				ThicknessReads = LayerMess<N,RLThickRead$>
				
				CONVERT @SVM TO @VM IN SheetRHOReads
				CONVERT @SVM TO @VM IN ThicknessReads
				
				A1 = SheetRHOReads
				
				RDSTestRec<RDS_TEST_READ_SHEET_RHO$>			= ICONV(OCONV(SheetRHOReads,'MD2'),'MD3')
				RDSTestRec<RDS_TEST_READ_THICK$>				= ThicknessReads
				
				
				RDSTestRec<RDS_TEST_THICK_AVG$>				= LayerMess<N,RLTThickAvg$>
				RDSTestRec<RDS_TEST_THICK_STDV$>			= LayerMess<N,RLTThickStdev$>
				RDSTestRec<RDS_TEST_THICK_UNIF$>			= LayerMess<N,RLTThickUnif$>
				RDSTestRec<RDS_TEST_THICK_MIN$>				= LayerMess<N,RLTThickMin$>
				RDSTestRec<RDS_TEST_THICK_MAX$>				= LayerMess<N,RLTThickMax$>
				
				
				IF ResUnits = SHEETRHO_SPEC_UNITS$ THEN
				
					RDSTestRec<RDS_TEST_SHEETRHO_AVG$>			= LayerMess<N,RLTResAvg$>
					RDSTestRec<RDS_TEST_SHEETRHO_STDV$>			= LayerMess<N,RLTResStdev$>
					RDSTestRec<RDS_TEST_SHEETRHO_UNIF$>			= LayerMess<N,RLTResUnif$>
					RDSTestRec<RDS_TEST_SHEETRHO_MIN$>			= LayerMess<N,RLTResMin$>
					RDSTestRec<RDS_TEST_SHEETRHO_MAX$>			= LayerMess<N,RLTResMax$>
					
					RDSTestRec<RDS_TEST_RES_AVG$>				= ''
					RDSTestRec<RDS_TEST_RES_STDV$>				= ''
					RDSTestRec<RDS_TEST_RES_UNIF$>				= ''
					RDSTestRec<RDS_TEST_RES_MIN$>				= ''
					RDSTestRec<RDS_TEST_RES_MAX$>				= ''
				
				END ELSE
				
					RDSTestRec<RDS_TEST_SHEETRHO_AVG$>			= ''
					RDSTestRec<RDS_TEST_SHEETRHO_STDV$>			= ''
					RDSTestRec<RDS_TEST_SHEETRHO_UNIF$>			= ''
					RDSTestRec<RDS_TEST_SHEETRHO_MIN$>			= ''
					RDSTestRec<RDS_TEST_SHEETRHO_MAX$>			= ''
					
					RDSTestRec<RDS_TEST_RES_AVG$>				= LayerMess<N,RLTResAvg$>
					RDSTestRec<RDS_TEST_RES_STDV$>				= LayerMess<N,RLTResStdev$>
					RDSTestRec<RDS_TEST_RES_UNIF$>				= LayerMess<N,RLTResUnif$>
					RDSTestRec<RDS_TEST_RES_MIN$>				= LayerMess<N,RLTResMin$>
					RDSTestRec<RDS_TEST_RES_MAX$>				= LayerMess<N,RLTResMax$>
				
				END
										
										
				FOR A = 11 TO 19
					RDSTestRec<A> = PSNLayerData<PRS_LAYER_THICK_MEASUREMENT$,A-10>
				NEXT A
					
				FOR A = 24 TO 32
					RDSTestRec<A> = PSNLayerData<PRS_LAYER_RES_MEASUREMENT$,A-23>
				NEXT A
				
				FOR A = 37 TO 45
					RDSTestRec<A> = PSNLayerData<PRS_LAYER_CONC_MEASUREMENT$,A-36>
				NEXT A
				
				FOR A = 50 to 58
					RDSTestRec<A> = PSNLayerData<PRS_LAYER_STRESS_MEASUREMENT$,A-49>
				NEXT A
				
				
				GOSUB LoadTestWafers
				
				RDSTestRec = obj_RDS_Test('CalcMissing',RDSTestRec)
				
				WRITE RDSTestRec ON RDSTestTable,NextTestKey ELSE NULL
				
			NEXT N
		END	;* End of check for Null RDS records
		
	END
REPEAT


* * * * * * * 
LoadTestWafers:
* * * * * * *

TWLine = 0

IF RDSRec<RDS_TW_NMINUS_CNT$> NE '' THEN
	TWType = 'N-'
	FOR T = 1 TO COUNT(RDSRec<RDS_TW_NMINUS_CODE$>,@VM) + (RDSRec<RDS_TW_NMINUS_CODE$> NE '')
		
		TWTool		= RDSRec<RDS_TW_NMINUS_TOOL$,T>
		TWCode		= RDSRec<RDS_TW_NMINUS_CODE$,T>
		TWTrans		= RDSRec<RDS_TW_NMINUS_TRANS$,T>
		TWCnt		= RDSRec<RDS_TW_NMINUS_CNT$,T>
		TWCon		= RDSRec<RDS_TW_NMINUS_CON$,T>
		TWRes		= RDSRec<RDS_TW_NMINUS_RES$,T>
		TWRho		= RDSRec<RDS_TW_NMINUS_RHO$,T>
		TWStress	= RDSRec<RDS_TW_NMINUS_STRESS$,T>
		TWThick		= RDSRec<RDS_TW_NMINUS_THICK$,T>

		GOSUB LoadTWLine
		
	NEXT T
END

IF RDSRec<RDS_TW_NPLUS_CNT$> NE '' THEN
	TWType = 'N+'
	FOR T = 1 TO COUNT(RDSRec<RDS_TW_NPLUS_CODE$>,@VM) + (RDSRec<RDS_TW_NPLUS_CODE$> NE '')
		
		TWTool		= RDSRec<RDS_TW_NPLUS_TOOL$,T>
		TWCode		= RDSRec<RDS_TW_NPLUS_CODE$,T>
		TWTrans		= RDSRec<RDS_TW_NPLUS_TRANS$,T>
		TWCnt		= RDSRec<RDS_TW_NPLUS_CNT$,T>
		TWCon		= RDSRec<RDS_TW_NPLUS_CON$,T>
		TWRes		= RDSRec<RDS_TW_NPLUS_RES$,T>
		TWRho		= RDSRec<RDS_TW_NPLUS_RHO$,T>
		TWStress	= RDSRec<RDS_TW_NPLUS_STRESS$,T>
		TWThick		= RDSRec<RDS_TW_NPLUS_THICK$,T>

		GOSUB LoadTWLine
		
	NEXT T
END

IF RDSRec<RDS_TW_PMINUS_CNT$> NE '' THEN
	TWType = 'P-'
	FOR T = 1 TO COUNT(RDSRec<RDS_TW_PMINUS_CODE$>,@VM) + (RDSRec<RDS_TW_PMINUS_CODE$> NE '')
		
		TWTool		= RDSRec<RDS_TW_PMINUS_TOOL$,T>
		TWCode		= RDSRec<RDS_TW_PMINUS_CODE$,T>
		TWTrans		= RDSRec<RDS_TW_PMINUS_TRANS$,T>
		TWCnt		= RDSRec<RDS_TW_PMINUS_CNT$,T>
		TWCon		= RDSRec<RDS_TW_PMINUS_CON$,T>
		TWRes		= RDSRec<RDS_TW_PMINUS_RES$,T>
		TWRho		= RDSRec<RDS_TW_PMINUS_RHO$,T>
		TWStress	= RDSRec<RDS_TW_PMINUS_STRESS$,T>
		TWThick		= RDSRec<RDS_TW_PMINUS_THICK$,T>

		GOSUB LoadTWLine
		
	NEXT T
END

IF RDSRec<RDS_TW_PPLUS_CNT$> NE '' THEN
	TWType = 'P+'
	FOR T = 1 TO COUNT(RDSRec<RDS_TW_PPLUS_CODE$>,@VM) + (RDSRec<RDS_TW_PPLUS_CODE$> NE '')
		
		TWTool		= RDSRec<RDS_TW_PPLUS_TOOL$,T>
		TWCode		= RDSRec<RDS_TW_PPLUS_CODE$,T>
		TWTrans		= RDSRec<RDS_TW_PPLUS_TRANS$,T>
		TWCnt		= RDSRec<RDS_TW_PPLUS_CNT$,T>
		TWCon		= RDSRec<RDS_TW_PPLUS_CON$,T>
		TWRes		= RDSRec<RDS_TW_PPLUS_RES$,T>
		TWRho		= RDSRec<RDS_TW_PPLUS_RHO$,T>
		TWStress	= RDSRec<RDS_TW_PPLUS_STRESS$,T>
		TWThick		= RDSRec<RDS_TW_PPLUS_THICK$,T>

		GOSUB LoadTWLine
		
	NEXT T
END

IF RDSRec<RDS_TW_PROD_CNT$> NE '' THEN
	TWType = 'Prod'
	FOR T = 1 TO COUNT(RDSRec<RDS_TW_PROD_CODE$>,@VM) + (RDSRec<RDS_TW_PROD_CODE$> NE '')
		
		TWTool		= RDSRec<RDS_TW_PROD_TOOL$,T>
		TWCode		= RDSRec<RDS_TW_PROD_CODE$,T>
		TWTrans		= RDSRec<RDS_TW_PROD_TRANS$,T>
		TWCnt		= RDSRec<RDS_TW_PROD_CNT$,T>
		TWCon		= RDSRec<RDS_TW_PROD_CON$,T>
		TWRes		= RDSRec<RDS_TW_PROD_RES$,T>
		TWRho		= RDSRec<RDS_TW_PROD_RHO$,T>
		TWStress	= RDSRec<RDS_TW_PROD_STRESS$,T>
		TWThick		= RDSRec<RDS_TW_PROD_THICK$,T>

		GOSUB LoadTWLine
		
	NEXT T
END

IF RDSRec<RDS_TW_RECLAIM_CNT$> NE '' THEN
	TWType = 'Reclaim'
	FOR T = 1 TO COUNT(RDSRec<RDS_TW_RECLAIM_CODE$>,@VM) + (RDSRec<RDS_TW_RECLAIM_CODE$> NE '')
		
		TWTool		= RDSRec<RDS_TW_RECLAIM_TOOL$,T>
		TWCode		= RDSRec<RDS_TW_RECLAIM_CODE$,T>
		TWTrans		= RDSRec<RDS_TW_RECLAIM_TRANS$,T>
		TWCnt		= RDSRec<RDS_TW_RECLAIM_CNT$,T>
		TWCon		= RDSRec<RDS_TW_RECLAIM_CON$,T>
		TWRes		= RDSRec<RDS_TW_RECLAIM_RES$,T>
		TWRho		= RDSRec<RDS_TW_RECLAIM_RHO$,T>
		TWStress	= RDSRec<RDS_TW_RECLAIM_STRESS$,T>
		TWThick		= RDSRec<RDS_TW_RECLAIM_THICK$,T>

		GOSUB LoadTWLine
		
	NEXT T
END

RETURN


* * * * * * *
LoadTWLine:
* * * * * * *

TWLine += 1

RDSTestRec<RDS_TEST_TW_TYPE$,TWLine>	= TWType
RDSTestRec<RDS_TEST_TW_TOOL$,TWLine>	= TWTool
RDSTestRec<RDS_TEST_TW_CODE$,TWLine>	= TWCode
RDSTestRec<RDS_TEST_TW_TRANS$,TWLine>	= TWTrans
RDSTestRec<RDS_TEST_TW_CNT$,TWLine>		= TWCnt
RDSTestRec<RDS_TEST_TW_CON$,TWLine>		= TWCon
RDSTestRec<RDS_TEST_TW_RES$,TWLine>		= TWRes
RDSTestRec<RDS_TEST_TW_RHO$,TWLine>		= TWRho
RDSTestRec<RDS_TEST_TW_STRESS$,TWLine>	= TWStress
RDSTestRec<RDS_TEST_TW_THICK$,TWLine>	= TWThick

RETURN


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

Return
