
! script name: vnvars.d/setactive
! var_topic: sets active variable toggle

!A
!A NAME:
!A
!A 	Set Active ( VARIABLE TOGGLE )
!A
!A DESCRIPTION:
!A
!A 	This script will set the active variable toggle.
!A
!B INSTRUCTIONS:
!B
!B 	NAME OF VARIABLE: Choose the variable from the select box.
!B
!C NOTE:
!C
!C 	Active and Inactive are flags on the variable which tell certain
!C 	scripts not to display the variables in selection boxes.
!C

stat=ChangeLabelStr("ScriptNameStatus","Function: set active variable toggle")

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

IF ARGC<2 THEN
        Set_active= 0
ELSE
        Set_active= VAL(ARGV(1))
END IF

DeActivateUndo
Start:!

Stat=UserSelectBox("VARIABLES","selected variable",WsVariationVars,WsVarSelect)
IF Stat=1 THEN Leave

Stat=SetInputFormat("a99","")
Stat=GetValue("NAME OF VARIABLE",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF (Answer$="CANCEL") THEN Leave

N=POS(Answer$,"=")
IF (N>1) THEN
	Answer$=Answer$[1,N-1]
	Answer$=TRIM$(Answer$)
END IF

Name$=Answer$
Edit_var=FindNamedVar(Name$,WsVariationVars)
IF (NOT ValidGeometry(Edit_var)) THEN Start
Stat=GeneralListBox(Descr$," ","  ,   ,   ")

Is_dependent= IsEntityDependent(Edit_var)
IF NOT Is_dependent THEN
	Stat= SetActiveEnt(Edit_var,Set_active)
END IF
GOTO Start


Leave:!

LowerSelectBox

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