
! script name: vnvars.d/vradius
! var_topic: make radius variable

!A
!A NAME:
!A
!A 	Radius (make variable)
!A
!A DESCRIPTION:
!A
!A 	This script makes a variable dependent on the radius 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 RADIUS: Select the circle to determine the radius.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: make radius 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 RADIUS",WsPickCircles)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_loop
Stat= EntityNameCheck(E1,Element$)


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

GOTO Name_loop



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