COMPILE ROUTINE LOAD_TUBE(Dummy)
ROWDEF(CHARSTR)

DECLARE SUBROUTINE obj_Schedule,Send_Dyn,Send_Info, Send_Dyn, obj_WO_Step, Set_Status, RList
DECLARE SUBROUTINE obj_Tube
DECLARE FUNCTION Get_Status, Set_Printer, obj_RDS


$INSERT REACTOR_LOG_EQU
$INSERT REACT_ITEMS_EQU
$INSERT REACT_TUBE_EQUATES
$INSERT TUBE_EQUATES

OPEN 'REACT_TUBE' TO ReactTubeTable ELSE
	DEBUG
	GOTO Bail
END

OPEN 'TUBE' TO TubeTable ELSE
	DEBUG
	GOTO Bail
END

SELECT TubeTable

Done = 0

RecCnt = 0

LOOP
	READNEXT TubeID ELSE Done = 1
UNTIL Done
	READ TubeRec FROM TubeTable,TubeID THEN
	
		RecCnt += 1
		
		ItemRec = XLATE('REACT_ITEMS',TubeID,'','X')
		
		Desc		= ItemRec<REACT_ITEMS_DESCRIPTION$>
		EnterDT 	= ItemRec<REACT_ITEMS_ENTRY_DATE$>
		EnterBy		= ItemRec<REACT_ITEMS_ENTRY_ID$>
		
		EnterDTM	= ICONV(OCONV(EnterDT,'D4/'):' 12:00:00','DT')
		

		TubeRec<TUBE_DESC$> 		= ItemRec<REACT_ITEMS_DESCRIPTION$>
		TubeRec<TUBE_ENTER_DTM$>	= EnterDTM
		TubeRec<TUBE_ENTER_BY$>  	= EnterBy
			
		*WRITE TubeRec ON TubeTable,TubeID THEN
			Send_Dyn('Tube ID: ':TubeID:' updated')
		*END
	END

REPEAT


GOTO Bail


SELECT ReactTubeTable


Done = 0

RecCnt = 0

LOOP
	READNEXT ReactNo ELSE Done = 1
UNTIL Done
	READ RTRec FROM ReactTubeTable,ReactNo THEN
		TubeIDCnt = COUNT(RTRec<REACT_TUBE_TUBE_ID$>,@VM) + (RTRec<REACT_TUBE_TUBE_ID$> NE '')
	
		FOR I = 1 TO TubeIDCnt
			TubeID =	RTRec<REACT_TUBE_TUBE_ID$,I>
			IF TubeID NE '' THEN
				READ TubeRec FROM TubeTable,TubeID ELSE TubeRec = ''
				InstDTM = RTRec<REACT_TUBE_INST_DTM$,I>
				
				LOCATE InstDTM IN TubeRec<TUBE_INST_DTM$> BY 'DR' USING @VM SETTING DPos THEN
					DEBUG
				END ELSE
					TubeRec = INSERT(TubeRec,TUBE_INST_DTM$,DPos,0,InstDTM)
					TubeRec = INSERT(TubeRec,TUBE_REACT_NO$,DPos,0,ReactNo)
					TubeRec = INSERT(TubeRec,TUBE_INST_REACT_HRS$,DPos,0,RTRec<REACT_TUBE_INST_REACT_HRS$,I>)
					TubeRec = INSERT(TubeRec,TUBE_INST_REACT_CYCLES$,DPos,0,RTRec<REACT_TUBE_INST_REACT_CYCLES$,I>)
					TubeRec = INSERT(TubeRec,TUBE_INST_RL_ID$,DPos,0,RTRec<REACT_TUBE_INST_RL_ID$,I>)
					TubeRec = INSERT(TubeRec,TUBE_RDS_WFR_CNT$,DPos,0,RTRec<REACT_TUBE_RDS_WAFER_CNT$,I>)
					TubeRec = INSERT(TubeRec,TUBE_REM_DTM$,DPos,0,RTRec<REACT_TUBE_REM_DTM$,I>)
					TubeRec = INSERT(TubeRec,TUBE_REM_REACT_HRS$,DPos,0,RTRec<REACT_TUBE_REM_REACT_HRS$,I>)
					TubeRec = INSERT(TubeRec,TUBE_REM_REACT_CYCLES$,DPos,0,RTRec<REACT_TUBE_REM_REACT_CYCLES$,I>)
					TubeRec = INSERT(TubeRec,TUBE_REM_RL_ID$,DPos,0,RTRec<REACT_TUBE_REM_RL_ID$,I>)
					
					WRITE TubeRec ON TubeTable,TubeID THEN
						RecCnt += 1
						Send_Info(RecCnt)
					END
					
				END
				
			END	;* End of check for null TubeID
		NEXT I
		
	END	;* End of RTRec Read
REPEAT



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

END

