COMPILE ROUTINE FIX_RDS_LAYER(Dummy)
ROWDEF(CHARSTR)

DECLARE SUBROUTINE Send_Dyn,Send_Info, Send_Dyn,  Set_Status,  RList, ErrMsg
DECLARE FUNCTION Get_Status,  ErrMsg, obj_Prod_Spec


$INSERT RDS_TEST_EQUATES
$INSERT RDS_EQU
$INSERT PROD_SPEC_EQU
$INSERT PRS_LAYER_EQU


OPEN 'RDS_LAYER' TO FileIn ELSE
	debug
	GOTO Bail
END

OPEN 'RDS_LAYER_WORK' TO FileOut ELSE
	debug
	GOTO Bail
END

OPEN 'RDS_TEST' TO TestFile ELSE
	DEBUG
	GOTO Bail
END

DEBUG

DELETE FileIn,'*'



SELECT FileIn

Done = 0
RecCnt = 0
FixCnt = 0


debug
LOOP
	READNEXT LayerKey ELSE Done = 1
UNTIL Done 
	IF INDEX(LayerKey,@VM,1) OR INDEX(LayerKey,@SVM,1)  OR LayerKey[-1,1] = '*' THEN
		
		READ JunkRec FROM FileIn,LayerKey THEN
			TestKeys = JunkRec<3>
			
			*DEBUG
			IF TestKeys NE '' THEN
				FOR I = 1 TO COUNT(TestKeys,@VM) + (TestKeys NE '')
					*DELETE TestFile,TestKeys<1,I> THEN
						Send_Dyn('RDS_TEST ':TestKeys<1,I>:' Removed')
					*END
				
				NEXT I
			END
			
			DELETE FileIn,LayerKey THEN
		
				Send_Dyn('RDS_LAYER ':LayerKey:' Removed')
				FixCnt += 1
			END
		END	;* End of Read
	END
	
	RecCnt += 1
	
	Send_Info(RecCnt:' - ':FixCnt)
	
REPEAT



Send_Dyn(RecCnt:' - ':FixCnt)

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

END



