
! script name: edit.d/editmaterial
! topic: edit material data file

!A
!A NAME:
!A
!A 	Material File
!A
!A DESCRIPTION:
!A
!A 	This script allows a material data file to be edited.  Once a
!A 	material has been selected a xed editor window will be brought
!A 	up to allow the editing of the material data file.
!A
!B INSTRUCTIONS:
!B
!B 	INPUT MATERIAL FILE NAME TO BE EDITED: The selection box with
!B 		the available list of material data files will automatically
!B 		appear for a selection to be made.  Once a selection has
!B 		been made, a xed editor window will be brought up with the
!B 		data that may be edited.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: material 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$[2000]
DIM Namelist2$[2000]
DIM Mask$[32]
DIM Editor$[256]

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

Start:!
Stat= NamedVarStr("material dir",WsSystemVars,"/usr/weber/util/tooldata/materials/",Dir$)
D_label$="MATERIALS DIRECTORY"
Choice$="MATERIALS SELECTED"
Mask$="*"
Stat=DirectoryNames(Dir$,Mask$,Namelist$)
Stat= AlphabeticalOrder(Namelist$,",",WsAscending,Namelist2$)
Stat=GeneralListBox(D_label$,Choice$,Namelist2$)

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

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

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