COMPILE ROUTINE FIX_TOOL(Dummy)
ROWDEF (CHARSTR)

DECLARE SUBROUTINE SEND_INFO, SEND_DYN, RList,Btree.Extract, Set_Status, Get_Status


$INSERT TOOL_EQUATES
$INSERT TOOL_LOG_EQUATES
$INSERT TOOL_CLASS_EQUATES

debug

OPEN 'TOOL' TO ToolTable ELSE
	Send_Info('Puked on tool table open.')
	GOTO Bail
END

OPEN 'TOOL_LOG' TO LogTable ELSE
	Send_Info('Puked on TOOL_LOG table open.')
	GOTO Bail
END

OPEN 'TOOL_CLASS' TO ToolClassTable ELSE
	Send_Info('Puked on TOOL_LOG table open.')
	GOTO Bail
END

OPEN 'LISTBOX_CONFIG' TO ListBoxTable ELSE
	Send_Info('Puked on LISTBOX_CONFIG table open.')
	GOTO Bail
END



SelectSent = 'SELECT TOOL WITH CLASS ] "G"'

RList(SelectSent,5)

DEBUG

Done = 0
LOOP
	READNEXT ToolID ELSE Done = 1
UNTIL Done
	READ ToolRec FROM ToolTable,ToolID THEN
		ToolRec<TOOL_TOOL_PROC$> = 'G'
		*WRITE ToolRec ON ToolTable,ToolID THEN
			Send_Dyn(ToolID:' ':ToolRec<TOOL_CLASS$>)
		*END
	END
REPEAT



GOTO Bail

ThickRec = XLATE('LISTBOX_CONFIG','THICKMEASURE',1,'X')

TCnt = COUNT(ThickRec,@VM) + (ThickRec NE '')

Send_Dyn('THICKMEASURE')

FOR I = 1 TO TCnt
	Line = ThickRec<1,I>
	Tool = FIELD(Line,' ',1)
	WfrType = FIELD(Line,' ',2,99)
	
	Send_Dyn(Tool:' - ':WfrType)
NEXT I



ResRec = XLATE('LISTBOX_CONFIG','RESMEASURE',1,'X')

RCnt = COUNT(ResRec,@VM) + (ResRec NE '')

Send_Dyn('RESMEASURE')

FOR I = 1 TO TCnt
	Line = ResRec<1,I>
	Tool = FIELD(Line,' ',1)
	WfrType = FIELD(Line,' ',2,99)
	
	Send_Dyn(Tool:' - ':WfrType)
NEXT I

GOTO Bail


SelectSent = 'SELECT LISTBOX_CONFIG WITH @ID CONTAINS "RECIPES"'

RList(SelectSent,5)


Done = 0
LOOP
	READNEXT ConfigKey ELSE Done = 1
UNTIL Done
	READ ConfigRec FROM ListBoxTable,ConfigKey THEN
	
		ToolKeys = ConfigRec<1>
		
		IF ConfigKey[-7,7] = 'RECIPES' THEN
			ConfigKey[-7,7] = ''
			CONVERT '_' TO '' IN ConfigKey
			
			BEGIN CASE
				CASE ConfigKey = 'SRP' 		; Tool = 'SRP'
				CASE ConfigKey = 'ADE'		; Tool = 'ADE'
				CASE ConfigKey = 'AKRION' 	; Tool = 'AKRION'
				CASE ConfigKey = 'FTIR'		; Tool = 'BIORAD'
				CASE ConfigKey = 'SURFSCAN'	; Tool = 'TENCOR'
				CASE ConfigKey = 'FLEXUS'	; Tool = 'FLEXUS'
				CASE ConfigKey = 'HGCV'		; Tool = 'HGCV'
				CASE ConfigKey = '4PP'		; Tool = '4PP'
				CASE 1	; Tool = ''
			END CASE
			
			IF Tool NE '' THEN
				READ ToolClassRec FROM ToolClassTable,Tool ELSE ToolClassRec = ''
				ToolClassRec<TOOL_CLASS_RECIPES$> = ConfigRec<1>
				WRITE ToolClassRec ON ToolClassTable,Tool THEN
					Send_Dyn(ConfigKey:' -> ':Tool)
				END
			END
		END
		
	END	;* End of read
	
REPEAT


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

END
