COMPILE FUNCTION RDS_METROLOGY(CtrlEntID,Event,Parm1,Parm2,Parm3,Parm4,Parm5,Parm6)
/*
	Commuter module for RDS_METROLOGY window.
	
	04/29/2009 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Set_Status, ErrMsg
DECLARE SUBROUTINE obj_Appwindow, Start_Window, Msg
DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Popup, Send_Event

$INSERT REACT_RUN_EQUATES
$INSERT RDS_LAYER_EQUATES
$INSERT RDS_TEST_EQUATES
$INSERT DICT_EQUATES

EQU CRLF$	TO \0D0A\

EQU COL$LS_ID		TO 1
EQU COL$MIN			TO 2
EQU COL$TARG		TO 3
EQU COL$MAX			TO 4
EQU COL$MTOOL		TO 5
EQU COL$MTYPE		TO 6
EQU COL$MRECIPE		TO 7
EQU COL$MFREQ		TO 8
EQU COL$MPROVEIN	TO 9
EQU COL$MFIRST		TO 10
EQU COL$MLAST		TO 11
EQU COL$MSPC		TO 12
EQU COL$MOVERGROW	TO 13

ErrTitle = 'Error in RDS_METROLGY commuter module'
ErrorMsg = ''

Result = ''

BEGIN CASE
	CASE Event = 'CREATE'	; GOSUB Create
	
	CASE 1
		ErrMsg(ErrTitle:@SVM:'Unknown parameters ':QUOTE(CtrlEntID):' ':QUOTE(Event):' passed to routine.')
		
END CASE


RETURN Result


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

obj_AppWindow('Create')

RDSNo = Parm1

IF RDSNo = '' THEN End_Dialog(@WINDOW)

DictFields = XLATE('DICT.RDS_TEST','%FIELDS%','','X')

LSIDs = XLATE('REACT_RUN',RDSNo,'RDS_LS_ID','X')			;* Layer Sets
LayerKeys = XLATE('REACT_RUN',RDSNo,'RDS_LS_SORTED','X')	;* RDS_LAYER Keys

LayerCnt = COUNT(LayerKeys,@VM) + (LayerKeys NE '')

ThickArray = ''
ResArray = ''
ConArray = ''
CResArray = ''

FOR I = 1 TO LayerCnt
	MetKey = XLATE('RDS_LAYER',LayerKeys<1,I>,RDS_LAYER_RDS_TEST_KEYS$,'X')<1,1>	;* 1st metrology key
	MetRec = XLATE('RDS_TEST',MetKey,'','X')
	
	LOCATE 'SPEC_THICK_MIN' IN DictFields<FIELDS_NAME$> USING @VM SETTING Pos THEN
		ThickConv = DictFields<FIELDS_CONV$,Pos>
	END
	
	ThickArray<COL$LS_ID,I> = LSIDs<1,I>
	ThickArray<COL$MIN,I>	= OCONV(MetRec<RDS_TEST_SPEC_THICK_MIN$>,ThickConv)
	ThickArray<COL$TARG,I>	= OCONV(MetRec<RDS_TEST_SPEC_THICK_TARGET$>,ThickConv)
	ThickArray<COL$MAX,I>	= OCONV(MetRec<RDS_TEST_SPEC_THICK_MAX$>,ThickConv)
	
	ThickArray<COL$MTOOL,I>		= MetRec<RDS_TEST_SPEC_THICK_MTOOL$>
	ThickArray<COL$MTYPE,I>		= MetRec<RDS_TEST_SPEC_THICK_MTYPE$>
	ThickArray<COL$MRECIPE,I>	= MetRec<RDS_TEST_SPEC_THICK_MRECIPE$>
	ThickArray<COL$MFREQ,I>		= MetRec<RDS_TEST_SPEC_THICK_MFREQ$>
	ThickArray<COL$MPROVEIN,I>	= MetRec<RDS_TEST_SPEC_THICK_MPROVEIN$>
	ThickArray<COL$MFIRST,I>	= OCONV(MetRec<RDS_TEST_SPEC_THICK_MFIRST$>,'B')
	ThickArray<COL$MLAST,I>		= OCONV(MetRec<RDS_TEST_SPEC_THICK_MLAST$>,'B')
	ThickArray<COL$MSPC,I>		= OCONV(MetRec<RDS_TEST_SPEC_THICK_MSPC$>,'B')
	ThickArray<COL$MOVERGROW,I>	= OCONV(MetRec<RDS_TEST_SPEC_THICK_MOVERGROW$>,'B')
	
	
	LOCATE 'SPEC_RES_MIN' IN DictFields<FIELDS_NAME$> USING @VM SETTING Pos THEN
		ResConv = DictFields<FIELDS_CONV$,Pos>
	END
	
	ResArray<COL$MIN,I>			= OCONV(MetRec<RDS_TEST_SPEC_RES_MIN$>,ResConv)
	
	IF ResArray<COL$MIN,I> NE '' THEN
		ResArray<COL$LS_ID,I> 		= LSIDs<1,I>
	END
	
	ResArray<COL$TARG,I>		= OCONV(MetRec<RDS_TEST_SPEC_RES_TARGET$>,ResConv)
	ResArray<COL$MAX,I>			= OCONV(MetRec<RDS_TEST_SPEC_RES_MAX$>,ResConv)
	ResArray<COL$MTOOL,I>		= MetRec<RDS_TEST_SPEC_RES_MTOOL$>
	ResArray<COL$MTYPE,I>		= MetRec<RDS_TEST_SPEC_RES_MTYPE$>
	ResArray<COL$MRECIPE,I>		= MetRec<RDS_TEST_SPEC_RES_MRECIPE$>
	ResArray<COL$MFREQ,I>		= MetRec<RDS_TEST_SPEC_RES_MFREQ$>
	ResArray<COL$MPROVEIN,I>	= MetRec<RDS_TEST_SPEC_RES_MPROVEIN$>
	ResArray<COL$MFIRST,I>		= OCONV(MetRec<RDS_TEST_SPEC_RES_MFIRST$>,'B')
	ResArray<COL$MLAST,I>		= OCONV(MetRec<RDS_TEST_SPEC_RES_MLAST$>,'B')
	ResArray<COL$MSPC,I>		= OCONV(MetRec<RDS_TEST_SPEC_RES_MSPC$>,'B')
	ResArray<COL$MOVERGROW,I>	= OCONV(MetRec<RDS_TEST_SPEC_RES_MOVERGROW$>,'B')
	
	
	LOCATE 'SPEC_CON_MIN' IN DictFields<FIELDS_NAME$> USING @VM SETTING Pos THEN
		ConConv = DictFields<FIELDS_CONV$,Pos>
	END
	
	ConArray<COL$MIN,I>			= OCONV(MetRec<RDS_TEST_SPEC_CON_MIN$>,ConConv)
	
	IF ConArray<COL$MIN,I> NE '' THEN
		ConArray<COL$LS_ID,I> 		= LSIDs<1,I>
	END
	
	ConArray<COL$TARG,I>		= OCONV(MetRec<RDS_TEST_SPEC_CON_TARGET$>,ConConv)
	ConArray<COL$MAX,I>			= OCONV(MetRec<RDS_TEST_SPEC_CON_MAX$>,ConConv)
	
	IF ConArray<COL$MIN,I> NE '' THEN
		ConArray<COL$LS_ID,I> 		= LSIDs<1,I>
	END
	
	ConArray<COL$MTOOL,I>		= MetRec<RDS_TEST_SPEC_CON_MTOOL$>
	ConArray<COL$MTYPE,I>		= MetRec<RDS_TEST_SPEC_CON_MTYPE$>
	ConArray<COL$MRECIPE,I>		= MetRec<RDS_TEST_SPEC_CON_MRECIPE$>
	ConArray<COL$MFREQ,I>		= MetRec<RDS_TEST_SPEC_CON_MFREQ$>
	ConArray<COL$MPROVEIN,I>	= MetRec<RDS_TEST_SPEC_CON_MPROVEIN$>
	ConArray<COL$MFIRST,I>		= OCONV(MetRec<RDS_TEST_SPEC_CON_MFIRST$>,'B')
	ConArray<COL$MLAST,I>		= OCONV(MetRec<RDS_TEST_SPEC_CON_MLAST$>,'B')
	ConArray<COL$MSPC,I>		= OCONV(MetRec<RDS_TEST_SPEC_CON_MSPC$>,'B')
	ConArray<COL$MOVERGROW,I>	= OCONV(MetRec<RDS_TEST_SPEC_CON_MOVERGROW$>,'B')
	
	
	LOCATE 'SPEC_CRES_MIN' IN DictFields<FIELDS_NAME$> USING @VM SETTING Pos THEN
		CResConv = DictFields<FIELDS_CONV$,Pos>
	END
	
	CResArray<COL$MIN,I>		= OCONV(MetRec<RDS_TEST_SPEC_CRES_MIN$>,CResConv)
	
	IF CresArray<COL$MIN,I> NE '' THEN
		CResArray<COL$LS_ID,I> 		= LSIDs<1,I>
	END
	
	CResArray<COL$TARG,I>		= OCONV(MetRec<RDS_TEST_SPEC_CRES_TARGET$>,CResConv)
	CResArray<COL$MAX,I>		= OCONV(MetRec<RDS_TEST_SPEC_CRES_MAX$>,CResConv)
	CResArray<COL$MTOOL,I>		= MetRec<RDS_TEST_SPEC_CRES_MTOOL$>
	CResArray<COL$MTYPE,I>		= MetRec<RDS_TEST_SPEC_CRES_MTYPE$>
	CResArray<COL$MRECIPE,I>	= MetRec<RDS_TEST_SPEC_CRES_MRECIPE$>
	CResArray<COL$MFREQ,I>		= MetRec<RDS_TEST_SPEC_CRES_MFREQ$>
	CResArray<COL$MPROVEIN,I>	= MetRec<RDS_TEST_SPEC_CRES_MPROVEIN$>
	CResArray<COL$MFIRST,I>		= OCONV(MetRec<RDS_TEST_SPEC_CRES_MFIRST$>,'B')
	CResArray<COL$MLAST,I>		= OCONV(MetRec<RDS_TEST_SPEC_CRES_MLAST$>,'B')
	CResArray<COL$MSPC,I>		= OCONV(MetRec<RDS_TEST_SPEC_CRES_MSPC$>,'B')
	CResArray<COL$MOVERGROW,I>	= OCONV(MetRec<RDS_TEST_SPEC_CRES_MOVERGROW$>,'B')
	
	
NEXT I

Set_Property(@WINDOW:'.ORIENT','DEFPROP',MetRec<RDS_TEST_SUB_ORIENTATION$>)

Set_Property(@WINDOW:'.THICK_SPEC','DEFPROP',ThickArray)
Set_Property(@WINDOW:'.RES_SPEC','DEFPROP',ResArray)
Set_Property(@WINDOW:'.CON_SPEC','DEFPROP',ConArray)
Set_Property(@WINDOW:'.CRES_SPEC','DEFPROP',CResArray)

RETURN


