
! script name: operations.d/editcurrop

!A
!A NAME:
!A
!A 	Edit Last Operation
!A
!A DESCRIPTION:
!A
!A 	This script allows the numeric data associated
!A 	with the last operation to be edited.
!A

stat=ChangeLabelStr("ScriptNameStatus","Function: edit last operation ")

COM /Ops_var_design/ Use_variational
DIM Destination$[256]
DIM Answer$[256]
DIM Datastr$[32000]
DIM Field$[256]
DIM Value$[256]
DIM Current_op$[256]

DeActivateUndo
Stat=NamedVarStr("current operation",WsSystemVars,"",Current_op$)
OperData=FindUserData(Current_op$,WsOperation)
IF NOT ValidGeometry(OperData) THEN Leave

Data_loop:!

Datastr$= ""

GOSUB Add_finish_depth
GOSUB Add_bore_depth
GOSUB Add_socket_depth
GOSUB Add_hole_dia
GOSUB Add_bore_dia
GOSUB Add_chamfer
GOSUB Add_corner_radius
GOSUB Add_length
GOSUB Add_width
GOSUB Add_angle
GOSUB Add_width_of_cut
GOSUB Add_finish_allow
GOSUB Add_mill_dir

Num_tools= GetUserValue(OperData,"Number tools:")
Datastr$= Datastr$&"Number tools: "&VAL$(Num_tools)&CHR$(10)

GOSUB Add_curr_tool
GOSUB Add_tools

Stat= GetUserString(OperData,"Operation script:",Answer$)
Datastr$= Datastr$&"Operation script: "&Answer$&CHR$(10)

Stat= GetUserString(OperData,"Tool script:",Answer$)
Datastr$= Datastr$&"Tool script: "&Answer$&CHR$(10)

Stat=GeneralListBox("OPERATION DATA","VALUE TO EDIT",Datastr$)
Stat=SetInputFormat("a99","")
Stat=GetValue("INPUT DATA TO BE CHANGED",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$= "CANCEL" THEN Leave

A= POS(Answer$,":")
IF A< 2 THEN Data_loop
Field$= Answer$[1,a]
Value$= Answer$[a+1]

SELECT Field$
CASE "Chamfer:","Length:","Width:","Finish allowance:","Width of cut:"
	Stat= SetInputFormat("n4=","")
	Stat= SetEqualsValue(VAL(Value$))
	Value= GetValue("NEW VALUE FOR "&Field$)
	IF ExitScript(Destination$) THEN Leave
	Stat= PutUserValue(OperData,Field$,Value)
CASE "Corner radius:","Finish depth:","Bore depth:","Socket depth:","Angle:","Hole diameter:","Bore diameter:"
	Stat= SetInputFormat("n4=","")
	Stat= SetEqualsValue(VAL(Value$))
	SELECT Field$
	CASE "Finish depth:","Bore depth:","Socket depth:"
		Value= InputDepth("NEW VALUE FOR "&Field$)
	CASE "Angle:"
		Value= InputAngle("NEW VALUE FOR "&Field$)
	CASE "Corner radius:"
		Value= InputRadius("NEW VALUE FOR "&Field$)
	CASE "Hole diameter:","Bore diameter:"
		Value= InputRadius("NEW VALUE FOR "&Field$,WsDiaInput)
	CASE ELSE
		Value= GetValue("NEW VALUE FOR "&Field$)
	END SELECT
	IF ExitScript(Destination$) THEN Leave
	Stat= PutUserValue(OperData,Field$,Value)
CASE "Number tools:","Current tool:"
	Stat= SetInputFormat("n0=","")
	Stat= SetEqualsValue(VAL(Value$))
	Value= GetValue("NEW VALUE FOR "&Field$)
	IF ExitScript(Destination$) THEN Leave
	Stat= PutUserValue(OperData,Field$,Value)
CASE "Operation script:","Tool script:"
	Stat= SetInputFormat("a99=","")
	Stat= SetEqualsValue(0,Value$)
	Stat= GetValue("NEW VALUE FOR "&Field$,Answer$)
	IF ExitScript(Destination$) THEN Leave
	Stat= PutUserString(OperData,Field$,Answer$)
CASE "Mill direction:"
	Mill_dir=GetUserString(OperData,"Mill direction:",Answer$)
	IF (Answer$="Climb") THEN
                stat= PutUserString(OperData,"Mill direction:","Conventional")
        ELSE
                stat= PutUserString(OperData,"Mill direction:","Climb")
        END IF
CASE ELSE
	IF LEN(Field$) > 6 THEN
		IF Field$[1,4]= "Tool" AND VAL(Field$[5]) THEN
			Stat= SetInputFormat("a99=","")
			Stat= SetEqualsValue(0,Value$)
			Stat= GetValue("NEW VALUE FOR "&Field$,Answer$)
			IF ExitScript(Destination$) THEN Leave
			Stat= PutUserString(OperData,Field$,Answer$)
		END IF
	END IF

END SELECT

GOTO Data_loop

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

Add_finish_depth:!
IF CheckUserField(OperData,"Finish depth:",0) THEN
	Finish_depth= GetUserValue(OperData,"Finish depth:")
	Datastr$= Datastr$&"Finish depth: "&VAL$(Finish_depth)&CHR$(10)
END IF
RETURN

Add_bore_depth:!
IF CheckUserField(OperData,"Bore depth:",0) THEN
	Bore_depth= GetUserValue(OperData,"Bore depth:")
	Datastr$= Datastr$&"Bore depth: "&VAL$(Bore_depth)&CHR$(10)
END IF
RETURN

Add_socket_depth:!
IF CheckUserField(OperData,"Socket depth:",0) THEN
	Socket_depth= GetUserValue(OperData,"Socket depth:")
	Datastr$= Datastr$&"Socket depth: "&VAL$(Socket_depth)&CHR$(10)
END IF
RETURN

Add_bore_dia:!
IF CheckUserField(OperData,"Bore diameter:",0) THEN
	Bdia= GetUserValue(OperData,"Bore diameter:")
	Datastr$= Datastr$&"Bore diameter: "&VAL$(Bdia)&CHR$(10)
END IF
RETURN

Add_hole_dia:!
IF CheckUserField(OperData,"Hole diameter:",0) THEN
	Dia= GetUserValue(OperData,"Hole diameter:")
	Datastr$= Datastr$&"Hole diameter: "&VAL$(Dia)&CHR$(10)
END IF
RETURN

Add_chamfer:!
IF CheckUserField(OperData,"Chamfer:",0) THEN
	Chamfer= GetUserValue(OperData,"Chamfer:")
	Datastr$= Datastr$&"Chamfer: "&VAL$(Chamfer)&CHR$(10)
END IF
RETURN

Add_tools:!

For J= 1 TO Num_tools
	IF CheckUserField(OperData,"Tool "&VAL$(J)&":",1) THEN
		Stat= GetUserString(OperData,"Tool "&VAL$(J)&":",Answer$)
		Datastr$= Datastr$&"Tool "&VAL$(J)&":"&Answer$&CHR$(10)
	END IF
NEXT J
RETURN

Add_curr_tool:!
IF CheckUserField(OperData,"Current tool:",0) THEN
	Curr_tool= GetUserValue(OperData,"Current tool:")
	Datastr$= Datastr$&"Current tool: "&VAL$(Curr_tool)&CHR$(10)
END IF
RETURN

Add_length:!
IF CheckUserField(OperData,"Length:",0) THEN
	Length= GetUserValue(OperData,"Length:")
	Datastr$= Datastr$&"Length: "&VAL$(Length)&CHR$(10)
END IF
RETURN

Add_angle:!
IF CheckUserField(OperData,"Angle:",0) THEN
	Angle= GetUserValue(OperData,"Angle:")
	Datastr$= Datastr$&"Angle: "&VAL$(Angle)&CHR$(10)
END IF
RETURN

Add_width:!
IF CheckUserField(OperData,"Width:",0) THEN
	Wid_= GetUserValue(OperData,"Width:")
	Datastr$= Datastr$&"Width: "&VAL$(Wid_)&CHR$(10)
END IF
RETURN

Add_width_of_cut:!
IF CheckUserField(OperData,"Width of cut:",0) THEN
	Width_cut= GetUserValue(OperData,"Width of cut:")
	Datastr$= Datastr$&"Width of cut: "&VAL$(Width_cut)&CHR$(10)
END IF
RETURN

Add_corner_radius:!
IF CheckUserField(OperData,"Corner radius:",0) THEN
	Corner_rad= GetUserValue(OperData,"Corner radius:")
	Datastr$= Datastr$&"Corner radius: "&VAL$(Corner_rad)&CHR$(10)
END IF
RETURN

Add_finish_allow:!
IF CheckUserField(OperData,"Finish allowance:",0) THEN
	Finish_allow= GetUserValue(OperData,"Finish allowance:")
	Datastr$= Datastr$&"Finish allowance: "&VAL$(Finish_allow)&CHR$(10)
END IF
RETURN

Add_mill_dir:!
IF CheckUserField(OperData,"Mill direction:",0) THEN
	Mill_dir= GetUserString(OperData,"Mill direction:",Answer$)
	Datastr$= Datastr$&"Mill direction: "&Answer$&CHR$(10)
END IF
RETURN
END
