
! script name: vnvars.d/vlinecomponent
! var_topic: make variable for the vector component of a line.

!A
!A NAME:
!A
!A 	Line Component
!A
!A DESCRIPTION:
!A
!A 	This script makes a variable dependent on the vector component of
!A	the first line in the direction of the second line.
!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 	FIRST LINE: Select the first line.
!B
!B 	DIRECTIONAL LINE: Select the line which determines the direction.
!B

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

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

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

DeActivateUndo
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



stat= SetInputFormat("n4","")
Pick_start:E1=PickSpecificEnt("FIRST LINE",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_start
Stat= EntityNameCheck(E1,Line1$)

Pick_end:!
E2=PickSpecificEnt("DIRECTIONAL LINE",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E2) THEN Pick_end
Stat= EntityNameCheck(E2,Line2$)


RecordFunctionOn
Stat= RecordDescr("VARIABLE: line vector component")
V1=NumericVariable(Name$,WsVariationVars,LineComponent(Line1$,Line2$))
stat= SetVariableDescr(V1,"Line Vector Component:")
RecordFunctionOff
CloseVarRecord

GOTO Name_loop



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