
! script name: vnvars.d/varlist
! var_topic: list variables

!A
!A NAME:
!A
!A 	Variable List
!A
!A DESCRIPTION:
!A
!A 	This script will list variational variables used.
!A
!B INSTRUCTIONS:
!B
!B	No user input required. 	
!B 

stat=ChangeLabelStr("ScriptNameStatus","Function: variable list ")

DIM Answer$[256]
DIM Destination$[256]
DIM File$[256]
DIM Title$[256]
DIM Name$[256]
DIM Var_val$[256]
DIM Var_type$[256]
DIM Descr$[256]
DIM A$[256]

File$= "tempdata"
Stat= RemoveFile("tempdata")

Group= GrpByEntType(WsNamedVarEnt)
IF NOT ValidGeometry(Group) THEN Leave

Is_written=0
Count1= GroupCount(group)
Stat= OutputString(File$,CHR$(10),WsNewFile)
FOR I=1 TO count1
	Edit_var= GroupElement(group,I)
	stat= ReadEntityName(Edit_var,Name$)
	Stat= GetVariableDescr(Edit_var,Descr$)
	IF LEN(Descr$) THEN Descr$= "Descr: "&Descr$
	Category= NamedVarCategory(Edit_var)
	IF Category= WsVariationVars THEN

		Is_active= IsEntityActive(Edit_var)
        	Is_dependent= IsEntityDependent(Edit_var)
		Var_subtype= GetVarSubtype(Edit_var)

		Var_type$=""
		IF Is_active THEN
			Var_type$= "active"
		ELSE
			IF Is_dependent THEN
				Var_type$= "dependent"
			END IF
		END IF

		SELECT Var_subtype
		CASE WsNVTypeOnOff
			Var_type$= Var_type$&" Switch:On/Off"
		CASE WsNVTypeTrueFalse
			Var_type$= Var_type$&" Switch:True/False"
		CASE WsNVTypeYesNo
			Var_type$= Var_type$&" Switch:Yes/No"
		CASE WsNVTypeFwdRev
			Var_type$= Var_type$&" Switch:Fwd/Rev"
		CASE WsNVTypeLeftRight
			Var_type$= Var_type$&" Switch:Left/Right"
		CASE WsNVTypeRadius
			Var_type$= Var_type$&" Type:Radius"
		CASE WsNVTypeDiameter
			Var_type$= Var_type$&" Type:Diameter"
		CASE WsNVTypeDepth
			Var_type$= Var_type$&" Type:Depth"
		CASE WsNVTypeAngle
			Var_type$= Var_type$&" Type:Angle"
		CASE WsNVTypeDir
			Var_type$= Var_type$&" Type:Directory"
		CASE WsNVTypeFilePath
			Var_type$= Var_type$&" Type:File path"
		CASE WsNVTypeBaseFile
			Var_type$= Var_type$&" Type:File name"
		CASE WsNVTypeToolName
			Var_type$= Var_type$&" Type:Tool name"
		CASE WsNVTypeColor
			Var_type$= Var_type$&" Type:Color"
		CASE WsNVTypeLayer
			Var_type$= Var_type$&" Type:Layer"
		CASE WsNVTypeLineType
			Var_type$= Var_type$&" Type:Linetype"
		END SELECT

		SELECT NamedVarTyp(Edit_var)
		CASE WsRealVar
       		 	A=GetVariableVal(Edit_var)
			Var_val$= VAL$(A)
		CASE WsStringVar
       			Stat=GetVariableStr(Edit_var,Answer$)
			Var_val$= Answer$
		CASE WsGeometryVar
			Var_val$= "GEOMETRY PTR"
		END SELECT
		A$= Name$&"= "&Var_val$&"  "&Var_type$&"  "&Descr$
       		Stat= OutputString(File$,A$&CHR$(10),WsAppend)
		Is_written=1
	END IF
NEXT I

Stat= DeleteEntity(Group)
IF NOT Is_written THEN Leave

Title$= "VARIABLES"
Stat=MessageFileBox(File$,Title$)

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