
! script name: edit.d/edittool
! topic: edit tool type file

!A
!A NAME:
!A
!A 	Tool File
!A
!A DESCRIPTION:
!A
!A 	This script allows a tool type file to be edited.  Once a tool
!A 	type has been selected the tools available for that type will
!A 	be brought up for a selection to be made.  Then a xed editor
!A 	window will be brought up to allow the editing of a particular
!A 	tool type tool.  Some examples of tool types are:
!A
!A 		reamers
!A 		endmills
!A 		taps
!A 		centerdrills
!A 		twistdrills
!A 		counterbores
!A
!A 	Remember, these tool types may vary depending on what has been
!A 	defined for the particular system being used.
!A
!B INSTRUCTIONS:
!B
!B 	INPUT TYPE OF TOOL: The selection box with the 	available list
!B 		of tool types will automatically appear for a selection
!B 		to be made.
!B
!B 	INPUT TOOL FILE NAME TO BE EDITED: Once a tool type has been
!B 		selected, the selection box with the list of TOOLS
!B 		AVAILABLE will automatically appear for a selection to
!B 		be made.  Once a selection has been made, a xed editor
!B 		window will be brought up with the data that may be edited.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: tool file ")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]
DIM File_name$[256]
DIM Dir$[256]
DIM D_label$[256]
DIM Choice$[256]
DIM Namelist$[32000]
DIM Namelist2$[32000]
DIM Mask$[32]
DIM Tool_class$[512]
DIM Editor$[256]

Stat= NamedVarStr("file editor",WsSystemVars,"notepad.exe",Editor$)
Flip_file= NamedVarVal("flip crlf",WsSystemVars,0)

Start:!
Units= CurrentUnits

Stat=SetInputFormat("a1=",",M,L,")
Stat=SetEqualsValue(0,"M")
Stat=GetValue("Mill or Lathe TOOL",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$="M" THEN
	Stat= NamedVarStr("tools dir",WsSystemVars,"/usr/weber/util/tooldata/tools_in/",Dir$)
ELSE
	Stat= NamedVarStr("ltools dir",WsSystemVars,"/usr/weber/util/tooldata/ltools_in/",Dir$)
END IF

D_label$="TOOL TYPE DIRECTORY"
Choice$="TOOL TYPE SELECTED"
Mask$="*"
Stat=DirectoryNames(Dir$,Mask$,Namelist$)
Stat= AlphabeticalOrder(Namelist$,",",WsAscending,Namelist2$)
Stat=GeneralListBox(D_label$,Choice$,Namelist2$)

Stat=SetInputFormat("a99","")
Stat=GetValue("INPUT TYPE OF TOOL",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$="CANCEL" THEN Leave
Tool_class$= FileNameString(Dir$,Answer$)

D_label$="TOOL AVAILABLE"
Choice$="TOOL SELECTED"
Mask$="[0-9,a-z,A-Z]*"
Stat=DirectoryNames(Tool_class$,Mask$,Namelist$)
Stat= AlphabeticalOrder(Namelist$,",",WsAscending,Namelist2$)
Stat=GeneralListBox(D_label$,Choice$,Namelist2$)

Stat=SetInputFormat("a99","")
Stat=GetValue("INPUT TOOL FILE NAME TO BE EDITED",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$="CANCEL" THEN Leave
File_name$= FileNameString(Tool_class$,Answer$)

Stat=EditFile(Editor$,File_name$,Flip_file)

Leave:!
LowerSelectBox
IF NOT LEN(Destination$) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
