
! script name: vnvars.d/vdiameter
! var_topic: make diameter variable

!A
!A NAME:
!A
!A 	Diameter (make variable)
!A
!A DESCRIPTION:
!A
!A 	This script makes a variable dependent on the diameter of a circle.
!A
!B INSTRUCTIONS:
!B
!B 	VARIABLE NAME: Enter the variable name.
!B
!B 	INVALID VARIABLE NAME: Name input was invalid choose new variable.
!B
!B 	PICK CIRCLE FOR DIAMETER: Select the circle to determine the diameter.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: make diameter variable")

DIM Answer$[256]
DIM Name$[256]
DIM Descr$[256]
DIM Element$[256]
DIM Destination$[256]
DEG

DeActivateUndo
Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave

Name_loop:!
stat= SetInputFormat("a99","")
Stat=GetValue("VARIABLE NAME",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Name$= Answer$
IF NOT ValidVariableName(Name$)	THEN
	stat= SetInputFormat("a99","")
	Stat=GetValue("INVALID VARIABLE NAME, Proceed",Answer$)
	IF (ExitScript(Destination$)) THEN Leave
	GOTO Name_loop
END IF

Pick_loop:Stat=SetInputFormat("n4","")
E1=PickSpecificEnt("PICK CIRCLE FOR DIAMETER ",WsPickCircles)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_loop
Stat= EntityNameCheck(E1,Element$)


RecordFunctionOn
Stat= RecordDescr("VARIABLE: Circle diameter")
V1=NumericVariable(Name$,WsVariationVars,2*ABS(CircleRadius(Element$)))
stat= SetVariableDescr(V1,"Circle diameter:")
RecordFunctionOff
CloseVarRecord

GOTO Name_loop



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