COMPILE ROUTINE FIX_RDS_MAKEUP(Dummy)
ROWDEF(CHARSTR)

DECLARE SUBROUTINE obj_Schedule,Send_Dyn,Send_Info, Send_Dyn, obj_WO_Step, Set_Status, Btree.Extract, obj_RDS, RList, ErrMsg
DECLARE SUBROUTINE Make.List
DECLARE FUNCTION Get_Status, Set_Printer, obj_RDS, ErrMsg

$INSERT RDS_MAKEUP_EQU

EQU TARGET_ACTIVELIST$ TO 5

EQU CRLF$ TO \0D0A\

OPEN 'RDS_MAKEUP' TO FileIn ELSE
	debug
	GOTO Bail
END

DEBUG

SELECT FileIn

Done = 0
LOOP
	READNEXT RdsNo ELSE Done = 1
UNTIL Done
	READ RDSRec FROM FileIn,RdsNo THEN
		
		WriteFlag = 0
		
		SrcRDSNos = RDSRec<RDS_MAKEUP_SRC_RDS$>
		IF INDEX(SrcRDSNos,RdsNo,1) THEN
			SlotCnt = COUNT(RDSRec<RDS_MAKEUP_SRC_RDS$>,@VM) + (RDSRec<RDS_MAKEUP_SRC_RDS$> NE '')
			WriteFlag = 0
			FOR I = 1 TO SlotCnt
				IF RDSRec<RDS_MAKEUP_SRC_RDS$,I> = RdsNo THEN
					RDSRec<RDS_MAKEUP_SRC_RDS$,I> = ''
					RDSRec<RDS_MAKEUP_SRC_SLOT$,I> = ''
					WriteFlag = 1
				END
			NEXT I
		END
		
		DestRDSNos = RDSRec<RDS_MAKEUP_DEST_RDS$>
		IF INDEX(DestRDSNos,RdsNo,1) THEN
			SlotCnt = COUNT(RDSRec<RDS_MAKEUP_DEST_RDS$>,@VM) + (RDSRec<RDS_MAKEUP_DEST_RDS$> NE '')
			
			FOR I = 1 TO SlotCnt
				IF RDSRec<RDS_MAKEUP_DEST_RDS$,I> = RdsNo THEN
					RDSRec<RDS_MAKEUP_DEST_RDS$,I> = ''
					RDSRec<RDS_MAKEUP_DEST_SLOT$,I> = ''
					WriteFlag = 1
				END
			NEXT I	
		END
		
		
		IF WriteFlag THEN

			WRITE RDSRec ON FileIn,RdsNo THEN
				Send_Dyn(RdsNo:' - Self Reference')
			END
		END
		
	END
REPEAT



GOTO Bail



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

END

