
! script name: operations.d/editoper2

!A
!A NAME:
!A
!A 	Edit Operation File
!A
!A DESCRIPTION:
!A
!A 	This script allows an operation file to be edited.  
!A
!B INSTRUCTIONS:
!B
!B 	INPUT OPERATION CLASS: The selection box with the available
!B 		list of operation classes that may be edited, will
!B 		automatically appear for a selection to be made.
!B
!B 	INPUT OPERATION FILE NAME TO BE EDITED: Once an operation class
!B 		has been selected, the 	selection box with the available
!B 		list of operation files will automatically appear for a
!B 		selection to be made.  Once a selection has been made, a
!B 		xed editor window will be brought up with the data that
!B 		may be edited.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: edit operation 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$[256]
DIM Op_class$[256]
DIM Editor$[256]

DeActivateUndo

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

Start:!
Stat=SetInputFormat("a1=",",M,L,")
Stat=SetEqualsValue(0,"M")
Stat=GetValue("Mill or Lathe OPERATION",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$="M" THEN
	Stat= NamedVarStr("operations dir",WsSystemVars,"/usr/weber/util/tooldata/operations2_in/",Dir$)
ELSE
	Stat= NamedVarStr("loperations dir",WsSystemVars,"/usr/weber/util/tooldata/loperations_in/",Dir$)
END IF

D_label$="OPERATION CLASS "
Choice$="OPERATION CLASS SELECTED"
Mask$="*"
Stat=DirectoryNames(Dir$,Mask$,Namelist$)
Stat= AlphabeticalOrder(Namelist$,",",WsAscending,Namelist2$)
Stat=GeneralListBox(D_label$,Choice$,Namelist2$)

Stat=SetInputFormat("a99","")
Stat=GetValue("INPUT OPERATION CLASS",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$="CANCEL" THEN Leave
Op_class$= FileNameString(Dir$,Answer$)

D_label$="OPERATIONS AVAILABLE"
Choice$="OPERATION SELECTED"
Mask$="[a-z,A-Z]*"
Stat=DirectoryNames(Op_class$,Mask$,Namelist$)
Stat= AlphabeticalOrder(Namelist$,",",WsAscending,Namelist2$)
Stat=GeneralListBox(D_label$,Choice$,Namelist2$)

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

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

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

