
! script name: tools.d/edittoolgeom
! topic: edit tool geometry

!A
!A NAME:
!A
!A 	Tool Geometry
!A
!A DESCRIPTION:
!A
!A 	Edit tool geometry.
!A

stat=ChangeLabelStr("ScriptNameStatus","Function: edit tool geometry ")

OPTION BASE 1

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]
DIM A$[256]
DIM B$[256]
DIM File_name$[256]
DIM New_file$[256]
DIM Toolid$[256]
DIM Toolmat$[256]
DIM Search1$[256]
DIM Search2$[256]
DIM Dir$[256]
DIM D_label$[256]
DIM Sub_label$[256]
DIM F_label$[256]
DIM Tool_class$[256]
DIM Choice$[256]
DIM Mask$[32]
DIM Namelist$[32000]
DIM Namelist2$[32000]
DIM Tool_data$[32000]
DIM Question$(20)[80]
DIM Reply$(20)[80]
DIM Fields$(20)[80]
DIM Class_dir$[256]
DIM Tool_name$[256]


DeActivateUndo
Display_data=0

Units= CurrentUnits
IF Units= WsMetric THEN
	Dim_offset= 20
	Dim_gap= 1
ELSE
	Dim_offset= 0.75
	Dim_gap= 0.030
END IF

Tool_layer= 132133
Tool_pen= 8
Dims_pen= 10
Text_pen= 3

Curr_layer= CurrentLayer


Start:!
Stat=RemoveDupTools
No_tools=ToolSelectBox("TOOLS","selected tool")
IF No_tools THEN Leave

Stat=SetInputFormat("a99","")
Stat=GetValue("TOOL TO BE EDITED",Name$)
IF ExitScript(Destination$) OR Name$="CANCEL" THEN Leave
Original_tool=FindUserData(Name$,WsToolData)
IF NOT ValidGeometry(Original_tool) THEN Start
LowerSelectBox
Tool= CopyEntity(Original_tool)


Edit_tool:!
Stat=GetUserString(Tool,"Tool type:",Toolid$)
Stat=GetUserString(Tool,"Tool id name:",Tool_name$)

CALL ToolFields(Fields$(*),Toolid$,Num_fields)

CALL ReadToolFields(Tool,Question$,Reply$,Fields$,Num_fields)

Stat= SetCurrentLayer(Tool_layer)
Stat= SetPlotLayers(","&VAL$(Tool_layer)&",")
Display_old_tool:!
UpdatePlot
GOSUB Plot_tool
ResizeAll

Edit_tool_ques:!
Stat= DisplayMessage(" ")
Stat=ChangeLabelStr("MultiLineShell",Tool_name$)
Input_stat=MultiInput(Question$(*),Reply$(*),1)
IF (ExitScript(Destination$)) THEN Leave
IF Input_stat=27 THEN Leave

CALL PutToolFields(Tool,Question$(*),Reply$(*),Fields$(*),Num_fields)

Display_new_tool:!
GOSUB Delete_dims
GOSUB Plot_tool

ResizeAll

IF Display_data THEN
	Stat= UserDataString(Tool,Tool_data$)
	File$="tempdata"
	Stat= OutputString(File$,Tool_data$,WsNewFile)
	Stat=MessageFileBox(File$,"NEW LIBRARY TOOL: "&Name$)
END IF

IF Input_stat=1 THEN Edit_tool_ques

F_type= DoesFileExist(New_file$)
Stat=SetInputFormat("a1",",Y,N,E,")
Stat=GetValue("RECORD CHANGES: Yes or No,  Edit ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$= "E" THEN
	GOTO Edit_tool_ques
END IF
IF Answer$= "Y" THEN 
	Stat= UserDataString(Tool,Tool_data$)
	Stat= ReplaceUserData(Original_tool,Tool_data$)
END IF
Stat= DeleteEntity(Tool)
GOSUB Delete_dims

GOTO Start

Plot_tool:!
StdWorkplane
! CALL DefineTool(Tool,Toolid$)
Stat=Setup3dCutter(Tool)
PlotOff
Ps= PointXYZ(0.0,0.0,0.0)
Pe= PointXYZ(-1.0,0.0,0.0)
Axis_line= LineTwoPoints(Ps,Pe)
Curr_pen= CurrentColor
Stat=SetCurrentColor(Tool_pen)
Cutter_solid= CutterSolid(Axis_line,WsTrue)
Stat=SetCurrentColor(Curr_pen)
Stat= DeleteEntity(Axis_line)
Stat= DeleteEntity(Ps)
Stat= DeleteEntity(Pe)
PlotOn
GOSUB  Diameter_dim
GOSUB  Flute_dim
IF Toolid$= "COUNTERBORE" THEN
	GOSUB  Pilot_dim
END IF
GOSUB  Holder_dim
GOSUB  Shank_dim
GOSUB  Tool_label
Stat= PlotEntity(Cutter_solid)
RETURN

Delete_dims:!
Stat= DeleteEntity(Cutter_solid)
Stat= DeleteEntity(Dia_dim)
Stat= DeleteEntity(Flute_dim)
Stat= DeleteEntity(Shank_dim)
Stat= DeleteEntity(Tool_label)
Stat= DeleteEntity(Holder_dim)
IF Toolid$= "COUNTERBORE" THEN
	Stat= DeleteEntity(Pilot_dim)
END IF
RETURN



Diameter_dim:!
PlotOff
Curr_pen= CurrentColor
Tool_dia=GetUserValue(Tool,"Diameter:")
Stat=SetCurrentColor(Dims_pen)
X1= Xcenter+ Dim_gap
Y1= Ycenter- 0.5*Tool_dia

X2= X1
Y2= Ycenter+ 0.5*Tool_dia

IF Tool_dia> .75*Dim_offset  THEN
        X3= Xcenter+ Dim_offset
        Y3= (Y1+Y2)/2
ELSE
        X3= Xcenter+ Dim_offset
        Y3= Y2+ 0.75*Dim_offset
END IF

Ps= PointXYZ(X1,Y1,0.0)
Pe= PointXYZ(X2,Y2,0.0)
Ploc= PointXYZ(X3,Y3,0.0)

PlotOn
Pre_text$= CHR$(129)&"  "
Dia_dim=LinearDim(WsVerticalDim,Ps,Pe,Ploc,0,CHR$(129)&" ","")
PlotOff
Stat= DeleteEntity(Ps)
Stat= DeleteEntity(Pe)
Stat= DeleteEntity(Ploc)
PlotOn
Stat=SetCurrentColor(Curr_pen)
RETURN

Shank_dim:!
PlotOff
Curr_pen= CurrentColor
Shank_dia=GetUserValue(Tool,"Shank diameter:")
IF Shank_dia<= 0 THEN
	Shank_dia=GetUserValue(Tool,"Body diameter:")
END IF
Total_length=GetUserValue(Tool,"Tip to holder:")
Stat=SetCurrentColor(Dims_pen)
X1= Xcenter- Total_length- Dim_gap
Y1= Ycenter- 0.5*Shank_dia

X2= X1
Y2= Ycenter+ 0.5*Shank_dia

IF Shank_dia> .75*Dim_offset  THEN
        X3= Xcenter-Total_length-Dim_offset
        Y3= (Y1+Y2)/2
ELSE
        X3= Xcenter-Total_length-Dim_offset
        Y3= Y2+ 0.75*Dim_offset
END IF

Ps= PointXYZ(X1,Y1,0.0)
Pe= PointXYZ(X2,Y2,0.0)
Ploc= PointXYZ(X3,Y3,0.0)

PlotOn
Pre_text$= CHR$(129)&"  "
Shank_dim=LinearDim(WsVerticalDim,Ps,Pe,Ploc,0,CHR$(129)&" ","")
PlotOff
Stat= DeleteEntity(Ps)
Stat= DeleteEntity(Pe)
Stat= DeleteEntity(Ploc)
PlotOn
Stat=SetCurrentColor(Curr_pen)
RETURN



Flute_dim:!
PlotOff
Curr_pen= CurrentColor
X_add= 0.0
SELECT Toolid$
CASE "COUNTERBORE"
        Pilot_len=GetUserValue(Tool,"Pilot length:")
        Flute_length=GetUserValue(Tool,"Flute length:")
        X_add= Pilot_len
CASE "COUNTER SINK"
        Overall_len=GetUserValue(Tool,"Overall length:")
        Shank_len=GetUserValue(Tool,"Shank length:")
        Flute_length=Overall_len-Shank_len
CASE "PORT CUTTER"
	Overall_len=GetUserValue(Tool,"Overall length:")
        Shank_len=GetUserValue(Tool,"Shank length:")
        Total_head_len=GetUserValue(Tool,"Total head length:")
        Flute_length=GetUserValue(Tool,"Minor diameter length:")
CASE "TAP","THREADER"
        Flute_length=GetUserValue(Tool,"Thread length:")
CASE ELSE
        Flute_length=GetUserValue(Tool,"Flute length:")
END SELECT
Stat=SetCurrentColor(Dims_pen)
X1= Xcenter- X_add
Y1= Ycenter- 0.5*Tool_dia- Dim_gap

X2= X1- Flute_length
Y2= Ycenter- 0.5*Tool_dia- Dim_gap

X3= (X1+X2)/2
Y3= Y1- Dim_offset

Ps= PointXYZ(X1,Y1,0.0)
Pe= PointXYZ(X2,Y2,0.0)
Ploc= PointXYZ(X3,Y3,0.0)

PlotOn
Flute_dim=LinearDim(WsHorizDim,Ps,Pe,Ploc,0,"","")
IF NOT ValidGeometry(Flute_dim) THEN
	Stat= DeleteEntity(Ploc)
	X3= X2- Dim_offset
	Ploc= PointXYZ(X3,Y3,0.0)
	Flute_dim=LinearDim(WsHorizDim,Ps,Pe,Ploc,0,"","")
END IF
PlotOff
Stat= DeleteEntity(Ps)
Stat= DeleteEntity(Pe)
Stat= DeleteEntity(Ploc)
PlotOn
Stat=SetCurrentColor(Curr_pen)
RETURN

Pilot_dim:!
IF Toolid$<> "COUNTERBORE" THEN RETURN
PlotOff
Curr_pen= CurrentColor
Pilot_len=GetUserValue(Tool,"Pilot length:")
Stat=SetCurrentColor(Dims_pen)
X1= Xcenter
Y1= Ycenter+ 0.5*Tool_dia- Dim_gap

X2= X1- Pilot_len
Y2= Ycenter+ 0.5*Tool_dia- Dim_gap

X3= (X1+X2)/2
Y3= Y1+ Dim_offset

Ps= PointXYZ(X1,Y1,0.0)
Pe= PointXYZ(X2,Y2,0.0)
Ploc= PointXYZ(X3,Y3,0.0)

PlotOn
Pilot_dim=LinearDim(WsHorizDim,Ps,Pe,Ploc,0,"","")
IF NOT ValidGeometry(Pilot_dim) THEN
	Stat= DeleteEntity(Ploc)
	X3= X2- Dim_offset
	Ploc= PointXYZ(X3,Y3,0.0)
	Pilot_dim=LinearDim(WsHorizDim,Ps,Pe,Ploc,0,"","")
END IF
PlotOff
Stat= DeleteEntity(Ps)
Stat= DeleteEntity(Pe)
Stat= DeleteEntity(Ploc)
PlotOn
Stat=SetCurrentColor(Curr_pen)
RETURN
Holder_dim:!
PlotOff
Curr_pen= CurrentColor
Total_length=GetUserValue(Tool,"Tip to holder:")
Stat=SetCurrentColor(Dims_pen)
X1= Xcenter
Y1= Ycenter- 0.5*Tool_dia- Dim_gap

X2= X1- Total_length
Y2= Ycenter- 0.5*Tool_dia- Dim_gap

X3= (X1+X2)/2
Y3= Y1- 1.5*Dim_offset

Ps= PointXYZ(X1,Y1,0.0)
Pe= PointXYZ(X2,Y2,0.0)
Ploc= PointXYZ(X3,Y3,0.0)

PlotOn
Holder_dim=LinearDim(WsHorizDim,Ps,Pe,Ploc,0,"","")
IF NOT ValidGeometry(Holder_dim) THEN
	Stat= DeleteEntity(Ploc)
	X3= X2- Dim_offset
	Ploc= PointXYZ(X3,Y3,0.0)
	Holder_dim=LinearDim(WsHorizDim,Ps,Pe,Ploc,0,"","")
END IF
PlotOff
Stat= DeleteEntity(Ps)
Stat= DeleteEntity(Pe)
Stat= DeleteEntity(Ploc)
PlotOn
Stat=SetCurrentColor(Curr_pen)
RETURN



Tool_label:!
Curr_pen= CurrentColor
Stat=SetCurrentColor(Text_pen)
Total_length=GetUserValue(Tool,"Tip to holder:")
Stat=GetUserString(Tool,"Tool id name:",Name$)
Tool_dia=GetUserValue(Tool,"Diameter:")

Tsize= GetDefault(WsTextWidth)
Tlen= LEN(Name$)*Tsize

X1= -(Total_length+Tlen)/2
Y1= 0.5*Tool_dia+ Dim_offset
Ps= PointXYZ(X1,Y1,0.0)
Tool_label= TextArrow(WsTextLine,Ps,Ps,Name$)
Stat= DeleteEntity(Ps)
Stat=SetCurrentColor(Curr_pen)

RETURN



Leave:!
LowerSelectBox
Stat= SetPlotLayers("")
Stat= SetInputFormat("n4","")
Stat= DeleteEntity(Dia_dim)
Stat= DeleteEntity(Flute_dim)
Stat= DeleteEntity(Pilot_dim)
Stat= DeleteEntity(Holder_dim)
Stat= DeleteEntity(Shank_dim)
Stat= DeleteEntity(Tool_label)
Stat= DeleteEntity(Tool)
Stat= DeleteEntity(Axis_line)
Stat= DeleteEntity(Ps)
Stat= DeleteEntity(Pe)
Stat= DeleteEntity(Cutter_solid)
Stat= SetCurrentLayer(Curr_layer)
PlotOn
UpdatePlot
ResizeAll
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END

SUB ReadToolFields(ENTITY Tool,Question$(*),Reply$(*),Fields$(*),Num_fields)
OPTION BASE 1
DIM A$[256],B$[256]

FOR I= 1 TO 20
	Question$(I)= ""
	Reply$(I)= ""
NEXT I

IF ValidGeometry(Tool) THEN 
	FOR I=1 TO Num_fields
		A$= Fields$(I)
		Stat=GetUserString(Tool,A$,B$)
		IF NOT Stat THEN
			Question$(I)= A$
			Reply$(I)= B$
		ELSE
			Question$(I)= A$
			Reply$(I)= VAL$(0)
		END IF
	NEXT I
END IF

SUBEND

SUB PutToolFields(ENTITY Tool,Question$(*),Reply$(*),Fields$(*),Num_fields)
OPTION BASE 1
DIM A$[256],B$[256]
DIM Name$[256]
DIM Tool_image$[256]

! Field #1 is the file name which is not in data.
! Assume fields 1,2,3 are string values.

IF ValidGeometry(Tool) THEN

	FOR I=1 TO 1
		A$= Fields$(I)
		B$= Reply$(I)
		Stat= PutUserString(Tool,A$,B$)
	NEXT I

	FOR I=2 TO Num_fields
		A$= Fields$(I)
		Stat= CheckUserField(Tool,A$,0)
		IF NOT Stat THEN
			B$= Reply$(I)
			Stat=  EvaluateAnswer(B$,Value)
			IF NOT Stat THEN
				Stat= PutUserValue(Tool,A$,Value)
			END IF
		ELSE
			B$= Reply$(I)
			Stat= PutUserString(Tool,A$,B$)
		END IF
	NEXT I

	Stat=GetUserString(Tool,"Tool id name:",Name$)
	Tool_image$= LWC$(Name$)
	
	Stat=PutUserString(Tool,"Tool image:",Tool_image$)

END IF


SUBEND


SUB DefineTool(Tool,Toolid$)

IF NOT ValidGeometry(Tool) THEN 
	SUBEXIT
END IF

Stat= Setup3DCutter(Tool)
SUBEXIT

Tip_angle=0
Taper= 0
Corner_chamfer=0
Crad=0
Shank_dia=0
D3=0
D4=0

Tdia=GetUserValue(Tool,"Diameter:")
Flute_length=GetUserValue(Tool,"Flute length:")
Total_length=GetUserValue(Tool,"Tip to holder:")

SELECT Toolid$
CASE "DRILL"
	Cutter_type= WsDrill
        Tip_angle=GetUserValue(Tool,"Point angle:")
	Shank_dia=GetUserValue(Tool,"Shank diameter:")
CASE "CENTER DRILL"
	Cutter_type= WsCenterDrill
        Tip_angle=GetUserValue(Tool,"Point angle:")
        Shank_dia=GetUserValue(Tool,"Body diameter:")
	Taper= 90- Tip_angle/2
CASE "TWIST DRILL"
	Cutter_type= WsTwistDrill
        Tip_angle=GetUserValue(Tool,"Point angle:")
	Shank_dia=GetUserValue(Tool,"Shank diameter:")
CASE "TAPERED DRILL"
	Cutter_type= WsTaperedDrill
        Tip_angle=GetUserValue(Tool,"Point angle:")
	Shank_dia=GetUserValue(Tool,"Shank diameter:")
	Taper=GetUserValue(Tool,"Taper angle:")
CASE "COUNTER SINK"
	Cutter_type= WsCounterSink
        Tip_angle=GetUserValue(Tool,"Point angle:")
	Overall_len=GetUserValue(Tool,"Overall length:")
        Shank_len=GetUserValue(Tool,"Shank length:")
        Shank_dia=GetUserValue(Tool,"Shank diameter:")
        Flute_length=Overall_len-Shank_len
CASE "COUNTERBORE"
	Cutter_type= WsCounterBore
	Crad=GetUserValue(Tool,"Corner radius:")
	Shank_dia=GetUserValue(Tool,"Shank diameter:")
        Pilot_dia=GetUserValue(Tool,"Pilot diameter:")
        Pilot_len=GetUserValue(Tool,"Pilot length:")
	D3= Pilot_dia
	D4= Pilot_len
CASE "TAP"
	Cutter_type= WsTap
	Thread_len=GetUserValue(Tool,"Thread length:")
        Shank_dia=GetUserValue(Tool,"Shank diameter:")
        Taper=0
	Tip_angle= 10
	Radius= 0.5*Tdia
	Crad= 0.5*Radius
	Flute_length= Thread_len
CASE "REAMER"
	Cutter_type= WsReamer
        Chamfer_length=GetUserValue(Tool,"Corner chamfer:")
        Shank_dia=GetUserValue(Tool,"Shank diameter:")
	Taper=10
	Radius= 0.5*Tdia
	Taper_length= 0.5*Radius
        Chamfer_angle=45
	Crad= Chamfer_length
	Tip_angle= Chamfer_angle
	D3= Taper_length
CASE "BALLMILL"
	Cutter_type= WsBallCutter
	Shank_dia=GetUserValue(Tool,"Shank diameter:")
CASE "BULLMILL"
	Cutter_type= WsBullmill
	Crad=GetUserValue(Tool,"Corner radius:")
	Shank_dia=GetUserValue(Tool,"Shank diameter:")
CASE "ENDMILL"
	Cutter_type= WsEndmill
	Shank_dia=GetUserValue(Tool,"Shank diameter:")
	Crad=GetUserValue(Tool,"Corner radius:")
CASE "TAPERMILL"
	Cutter_type= WsTaperedEndmill
	Shank_dia=GetUserValue(Tool,"Shank diameter:")
	Taper=GetUserValue(Tool,"Taper angle:")
	Crad=GetUserValue(Tool,"Corner radius:")
CASE "TAPERBALL"
	Cutter_type= WsBallCutter
	Shank_dia=GetUserValue(Tool,"Shank diameter:")
	Taper=GetUserValue(Tool,"Taper angle:")
CASE "CHAMFERMILL"
	Cutter_type= WsChamferTool
	Shank_dia=GetUserValue(Tool,"Shank diameter:")
	Radius= 0.5*Tdia
        Tip_radius=GetUserValue(Tool,"Tip diameter:")/2
	Chamfer_angle=GetUserValue(Tool,"Taper angle:")
	Chamfer_length= (Radius- Tip_radius)/TAN(Chamfer_angle)
	Crad= Chamfer_length
	Tip_angle= Chamfer_angle
CASE "THREADER"
	Cutter_type= WsThreadedMill
	Shank_dia=GetUserValue(Tool,"Shank diameter:")
	Flute_length=GetUserValue(Tool,"Thread length:")
CASE "BORING BAR"
	Cutter_type= WsBoringBar
        Crad=GetUserValue(Tool,"Corner radius:")
        Shank_dia=GetUserValue(Tool,"Shank diameter:")
END SELECT


Radius= 0.5*Tdia
Shank_radius= 0.5*Shank_dia
Stat=Setup3dCutter(Cutter_type,Radius,Crad,0.0,0.0,Taper,Flute_length,Tip_angle,Shank_radius,Total_length,D3,D4)


SUBEND

SUB ToolFields(Fields$(*),Toolid$,Num_fields)
OPTION BASE 1

SELECT Toolid$
CASE "ENDMILL"
	Fields$(1)="Tool material:"
	Fields$(2)="Diameter:"
        Fields$(3)="Corner radius:"
	Fields$(4)="Gage length:"
	Fields$(5)="Shank diameter:"
	Fields$(6)="Flute length:"
	Fields$(7)="Tip to holder:"
	Fields$(8)="CNC tool-pocket number:"
	Num_fields= 8
CASE "BULLMILL"
        Fields$(1)="Tool material:"
        Fields$(2)="Diameter:"
        Fields$(3)="Corner radius:"
        Fields$(4)="Gage length:"
        Fields$(5)="Shank diameter:"
        Fields$(6)="Flute length:"
	Fields$(7)="Tip to holder:"
	Fields$(8)="CNC tool-pocket number:"
	Num_fields= 8
CASE "TAPERMILL"
        Fields$(1)="Tool material:"
        Fields$(2)="Diameter:"
        Fields$(3)="Corner radius:"
        Fields$(4)="Gage length:"
        Fields$(5)="Shank diameter:"
        Fields$(6)="Flute length:"
	Fields$(7)="Tip to holder:"
        Fields$(8)="Taper angle:"
	Fields$(9)="CNC tool-pocket number:"
	Num_fields= 9
CASE "TAPERBALL"
        Fields$(1)="Tool material:"
        Fields$(2)="Diameter:"
        Fields$(3)="Gage length:"
        Fields$(4)="Shank diameter:"
        Fields$(5)="Flute length:"
	Fields$(6)="Tip to holder:"
        Fields$(7)="Taper angle:"
	Fields$(8)="CNC tool-pocket number:"
	Num_fields= 8
CASE "THREADER"
	Fields$(1)="Tool id name:"
	Fields$(2)="Tool material:"
	Fields$(3)="Diameter:"
	Fields$(4)="Gage length:"
	Fields$(5)="Shank diameter:"
	IF CurrentUnits= WsMetric THEN
		Fields$(6)= "Pitch:"
	ELSE
		Fields$(6)= "Threads-inch:"
	END IF
        Fields$(7)="Thread length:"
	Fields$(8)="Tip to holder:"
	Fields$(9)="CNC tool-pocket number:"
	Num_fields= 9
CASE "BORING BAR"
        Fields$(1)="Tool material:"
        Fields$(2)="Diameter:"
        Fields$(3)="Corner radius:"
        Fields$(4)="Gage length:"
        Fields$(5)="Shank diameter:"
        Fields$(6)="Flute length:"
	Fields$(7)="Tip to holder:"
	Fields$(8)="CNC tool-pocket number:"
	Num_fields= 8
CASE "BALLMILL"
        Fields$(1)="Tool material:"
        Fields$(2)="Diameter:"
        Fields$(3)="Gage length:"
        Fields$(4)="Shank diameter:"
        Fields$(5)="Flute length:"
	Fields$(6)="Tip to holder:"
	Fields$(7)="CNC tool-pocket number:"
	Num_fields= 7
CASE "CHAMFERMILL"
        Fields$(1)="Tool material:"
        Fields$(2)="Diameter:"
        Fields$(3)="Tip diameter:"
        Fields$(4)="Gage length:"
        Fields$(5)="Shank diameter:"
        Fields$(6)="Flute length:"
	Fields$(7)="Tip to holder:"
        Fields$(8)="Taper angle:"
	Fields$(9)="CNC tool-pocket number:"
	Num_fields= 9
CASE "DRILL","TWIST DRILL"
        Fields$(1)= "Tool material:"
        Fields$(2)= "Diameter:"
        Fields$(3)= "Gage length:"
        Fields$(4)= "Shank diameter:"
        Fields$(5)= "Flute length:"
	Fields$(6)= "Tip to holder:"
        Fields$(7)= "Point angle:"
        Fields$(8)= "Feed(ipr):"
	Fields$(9)="CNC tool-pocket number:"
	Num_fields= 9
CASE "CENTER DRILL"
        Fields$(1)= "Tool material:"
        Fields$(2)= "Diameter:"
        Fields$(3)= "Gage length:"
        Fields$(4)= "Body diameter:"
        Fields$(5)= "Flute length:"
        Fields$(6)= "Tip to holder:"
        Fields$(7)= "Point angle:"
        Fields$(8)= "Feed(ipr):"
	Fields$(9)="CNC tool-pocket number:"
        Num_fields= 9
CASE "TAPERED DRILL"
        Fields$(1)= "Tool material:"
        Fields$(2)= "Diameter:"
        Fields$(3)= "Gage length:"
        Fields$(4)= "Shank diameter:"
        Fields$(5)= "Flute length:"
        Fields$(6)= "Point angle:"
	Fields$(7)="Tip to holder:"
        Fields$(8)= "Taper angle:"
        Fields$(9)= "Feed(ipr):"
	Fields$(10)="CNC tool-pocket number:"
	Num_fields= 10
CASE "COUNTER SINK"
        Fields$(1)= "Tool material:"
        Fields$(2)= "Diameter:"
        Fields$(3)= "Gage length:"
        Fields$(4)= "Shank diameter:"
        Fields$(5)= "Shank length:"
        Fields$(6)= "Overall length:"
        Fields$(7)= "Flute length:"
	Fields$(8)= "Tip to holder:"
        Fields$(9)= "Point angle:"
        Fields$(10)= "Feed(ipr):"
	Fields$(11)="CNC tool-pocket number:"
	Num_fields= 11
CASE "COUNTERBORE"
        Fields$(1)= "Tool material:"
        Fields$(2)= "Diameter:"
        Fields$(3)= "Gage length:"
        Fields$(4)= "Shank diameter:"
        Fields$(5)= "Pilot diameter:"
        Fields$(6)= "Pilot length:"
        Fields$(7)= "Flute length:"
	Fields$(8)="Tip to holder:"
	Fields$(9)="CNC tool-pocket number:"
	Num_fields= 9
CASE "REAMER"
        Fields$(1)= "Tool material:"
        Fields$(2)= "Diameter:"
        Fields$(3)= "Corner chamfer:"
        Fields$(4)= "Gage length:"
        Fields$(5)= "Shank diameter:"
        Fields$(6)= "Flute length:"
	Fields$(7)="Tip to holder:"
        Fields$(8)= "Feed(ipr):"
	Fields$(9)="CNC tool-pocket number:"
	Num_fields= 9
CASE "TAP"
        Fields$(1)= "Tool material:"
        Fields$(2)= "Diameter:"
        Fields$(3)= "Gage length:"
        Fields$(4)= "Shank diameter:"
	IF CurrentUnits= WsMetric THEN
		Fields$(5)= "Pitch:"
	ELSE
		Fields$(5)= "Threads-inch:"
	END IF
        Fields$(6)= "Thread length:"
	Fields$(7)="Tip to holder:"
	Fields$(8)="CNC tool-pocket number:"
	Num_fields= 8
CASE "PORT CUTTER"
        Fields$(1)= "Tool id name:"
        Fields$(2)= "Tool material:"
        Fields$(3)= "Diameter:"
        Fields$(4)= "Minor diameter:"
        Fields$(5)= "Minor diameter length:"
        Fields$(6)= "Seal angle:"
        Fields$(7)= "Seal angle dia:"
        Fields$(8)= "Seal angle length:"
        Fields$(9)= "Point angle:"
        Fields$(10)= "Total head length:"
        Fields$(11)= "Overall length:"
        Fields$(12)= "Shank diameter:"
	Fields$(13)="Tip to holder:"
        Fields$(14)= "Feed(ipr):"
	Fields$(15)="CNC tool-pocket number:"
	Num_fields= 15
END SELECT

SUBEND
