COMPILE ROUTINE LOAD_CALIB_LIST(Dummy)
ROWDEF (CHARSTR)

DECLARE SUBROUTINE SEND_INFO, SEND_DYN, Utility, msg
DECLARE FUNCTION NextKey

$INSERT MASTER_CALIB_LIST_EQU
$INSERT CALIB_LIST_EQUATES
$INSERT CALIBRATION_EQUATES


EQU CRLF$ TO \0D0A\

OPEN 'CALIB_LIST' TO FileIn ELSE
	DEBUG
	GOTO Bail
END

OPEN 'CALIBRATION' TO FileOut ELSE
	DEBUG
	GOTO Bail
END

DEBUG

SELECT FileIn

CalRec = ''
CalRec<CALIBRATION_NOTES$> = 'Generated from CALIB_LIST record.'
Done = 0
LOOP
	READNEXT CLNo ELSE Done = 1
UNTIL Done
	READ CLRec FROM FileIn,CLNo THEN
		CalDts = CLRec<CALIB_LIST_LAST_CAL_DT$>
		CalCnt = COUNT(CalDts,@VM) + (CalDts NE '')
			
		FOR I = 1 TO CalCnt
			CalKey = CLNo:'*':CalDts<1,I>
			WRITE CalRec ON FileOut,CalKey THEN
				Send_Dyn(CalKey)
			END
			
		NEXT I
	END
REPEAT


GOTO Bail



DataIn = XLATE('CONFIG','MASTER_CALIB_LIST','','X')

debug

EquipCnt = COUNT(DataIn<1>,@VM) + (DataIn<1> NE '')

FOR I = 3 TO EquipCnt
	CLKey = NextKey('CALIB_LIST')
	NewRec = ''
	NewRec<CALIB_LIST_CL_TYPE$> 		= 'E'
	NewRec<CALIB_LIST_EQ_DESC$>			= DataIn<MasterCalibListInstrument$,I>
	NewRec<CALIB_LIST_EQ_SN$>			= DataIn<MasterCalibListEquipSN$,I>
	NewRec<CALIB_LIST_EQ_LOC$>			= DataIn<MasterCalibListEquipLoc$,I>
	NewRec<CALIB_LIST_EQ_LEVEL$>		= DataIn<MasterCalibListEquipClass$,I>
	NewRec<CALIB_LIST_EQ_CAL_CLASS$>	= DataIn<MasterCalibListEquipCalClass$,I>
	NewRec<CALIB_LIST_CAL_INTERVAL$>	= DataIn<MasterCalibListEquipCalInterval$,I>
	NewRec<CALIB_LIST_CAL_INT_EXT$>		= DataIn<MasterCalibListEquipIntExt$,I>
	NewRec<CALIB_LIST_LAST_CAL_DT$>		= DataIn<MasterCalibListEquipLastCalDate$,I>
	NewRec<CALIB_LIST_NEXT_CAL_DT$>		= DataIn<MasterCalibListEquipNextCalDate$,I>
	WRITE NewRec ON FileOut,CLKey THEN
		Send_Dyn(CLKey)
	END
NEXT I
	
	
StdCnt = COUNT(DataIn<MasterCalibListNISTStandard$>,@VM) + (DataIn<MasterCalibListNISTStandard$> NE '')

FOR I = 1 TO StdCnt
	CLKey = NextKey('CALIB_LIST')
	NewRec = ''
	NewRec<CALIB_LIST_CL_TYPE$> 		= 'S'
	NewRec<CALIB_LIST_STD_DESC$>			= DataIn<MasterCalibListNISTStandard$,I>
	NewRec<CALIB_LIST_STD_SN$>			= DataIn<MasterCalibListNISTSN$,I>
	NewRec<CALIB_LIST_STD_LOC$>			= DataIn<MasterCalibListNISTLoc$,I>
	
	NewRec<CALIB_LIST_CAL_INTERVAL$>	= DataIn<MasterCalibListNISTCalInterval$,I>
	NewRec<CALIB_LIST_CAL_INT_EXT$>		= DataIn<MasterCalibListNISTIntExt$,I>
	NewRec<CALIB_LIST_LAST_CAL_DT$>		= DataIn<MasterCalibListNISTLastCalDate$,I>
	NewRec<CALIB_LIST_NEXT_CAL_DT$>		= DataIn<MasterCalibListNISTNextCalDate$,I>
 	WRITE NewRec ON FileOut,CLKey THEN
		Send_Dyn(CLKey)
	END
NEXT I
	
	
	
	
* * * * * * *
Bail:
* * * * * * *

END
