
! script name: vnvars.d/vdescription
! var_topic: add description to variable

!A
!A NAME:
!A
!A 	Add Description
!A
!A DESCRIPTION:
!A
!A 	This script allows the user to add a description to a variable.
!A
!B INSTRUCTIONS:
!B
!B 	NAME OF VARIABLE: Pick the variable from the selection box.	
!B
!B 	VARIABLE DESCRIPTION, None: Input the description to be applied
!B 		to the variable. None will cancel any existing description.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: add variable description")

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

DeActivateUndo
Generation= 3
Highlight_color=2
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= GetVariableDescr(Edit_var,Descr$)
Stat=GeneralListBox(Descr$," ","  ,   ,   ")
Stat= ShowDependency(Name$,Generation,Highlight_color)

stat= SetEditString(Descr$)
stat= SetInputFormat("a99","")
Stat=GetValue("VARIABLE DESCRIPTION, None  ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Descr$= Answer$
IF Answer$="N" OR Answer$="None" OR Answer$= "NONE" OR Answer$="n" THEN
        Descr$=""
END IF

stat= SetVariableDescr(Edit_var,Descr$)

GOTO Start


Leave:!

LowerSelectBox

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