
! script name: vholes.d/editholedepth
! var_topic: edit hole depth

!A
!A NAME:
!A
!A 	Edit Hole Depth (VARIATIONAL)
!A
!A DESCRIPTION:
!A
!A 	This script allows the depth of an existing hole to be changed.
!A
!B INSTRUCTIONS:
!B
!B 	FINISH DEPTH: Enter the new depth for the hole.
!B
!B 	PICK HOLE, New Depth: Pick the hole point to be modified.
!B
!B 		N - New Depth allows the option of entering a new depth.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: edit hole depth ")

DIM Destination$[256]
DIM Answer$[256]
DIM Depth_var$[256]
DIM Hole_name$[256]

Var_object= CheckVarObject
IF ExitScript(Destination$) THEN Leave

ActivateUndo
Ask_depth:!
Depthr=NamedVarVal("hole depth",WsPointVars,0.0)
Stat=SetDepthEquals(Depthr)

Stat=SetInputFormat("n4","")
Depth=InputDepth("FINISH DEPTH")
IF (ExitScript(Destination$)) THEN Leave
No_depth_var= LastVariableInput(Depth_var$)
Depthr= Depth
Vdepth=CreateVariable("hole depth",WsPointVars,Depthr)

Hole_loop:Stat=SetInputFormat("n4a1",",N,")
H1=PickEntity("PICK HOLE, New depth",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$= "N" THEN Ask_depth
Stat= ReadEntityName(H1,Hole_name$)
IF NOT LEN(Hole_name$) THEN
        Stat= AutoNameEntity(H1)
        Stat= ReadEntityName(H1,Hole_name$)
END IF
Etype= EntityType(H1)
IF Etype <> WsHoleEnt THEN Hole_loop

ActivateUndo
Stat= AdvanceUndoNumber("change depth")
Stat= AddItemToUndo(WsUBModifyMode,H1)

RecordFunctionOn
Stat= RecordDescr("HOLE: Change depth")
IF No_depth_var THEN
        V1= FreeParameter("Finish depth",Depth)
	Stat= ChHoleDepth(Hole_name$,V1)
ELSE
	Stat= ChHoleDepth(Hole_name$,Depth_var$)
END IF
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Hole_loop

Leave:!
Stat=SetInputFormat("n4","")
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
