
! script name: vedit.d/chfeatzone
! var_topic: change the workzone of a holefeature

!A
!A NAME:
!A
!A 	Change the workzone of a holefeature
!A
!A DESCRIPTION:
!A
!A
!B INSTRUCTIONS:
!B
!B	CHOOSE FEATURE TO EDIT: Pick the feature name that you want to edit
!B
!B 	WORKZONE NUMBER: Enter the workzone number.
!B
!B
!C NOTE: 
!C
!C	The workzone number of the feature record is applied to all
!C	hole features created by the same feature definition.
!C

Stat=ChangeLabelStr("ScriptNameStatus","Function: change feature zone ")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]
DIM Descr$[256]
DIM Namelist$[32000],List_str$[256]
DIM Namelist2$[32000]
DIM Feat_desc$[256]

DeActivateUndo
Stat=LineNumberIncr(1)
Start_obj=0
Highlight_color=2

Start:!
Quote$=CHR$(34)
Commastr$=","
Spacestr$=" "

!Record_group= SearchRecordDescr(Search1$,True= Match Partial,True= Remove Dups)

Group= SearchRecordDescr("FEATURE DATA:",WsTrue,WsFalse)
IF NOT ValidGeometry(Group) THEN Leave

Namelist$= ""
Num_recs= GroupCount(Group)
FOR I= 1 TO Num_recs
        Op_record= GroupElement(Group,I)
        Stat= GetDescription(Op_record,Feat_desc$)
        J= POS(Feat_desc$,":")
        Namelist$= Namelist$&VAL$(I)&".) "&TRIM$(Feat_desc$[J+1])&Commastr$
NEXT I

Ask_ques:Stat=GeneralListBox("Features","Feature Chosen",Namelist$)
Stat= SetInputFormat("a99","")
Stat= GetValue("CHOOSE FEATURE TO EDIT ",Answer$)
IF ExitScript(Destination$) OR Answer$="CANCEL" THEN Leave
FOR K= 1 TO Num_recs
	Stat= StringFieldStr(Namelist$,Commastr$,K,List_str$)
	IF List_str$= Answer$ THEN Pick_record
NEXT K
GOTO Ask_ques

Pick_record:!
Var_record= GroupElement(Group,K)
Var_object=VarObjectParent(Var_record)

Start_obj=VarObjectNumber(Var_object)

Zone_number:!
GOSUB Zone_list
Wzone=GetWorkZone(Var_record)
Stat= SetInputFormat("a99=","")
Stat= SetEqualsValue(Wzone,VAL$(Wzone))
E1= PickEntity("WORK ZONE NUMBER ",Answer$)
IF ExitScript(Destination$) OR Answer$="CANCEL" THEN Leave
IF ValidGeometry(E1) THEN
	Wzone=GetWorkZone(E1)
ELSE
	Wzone= NumericPrefix(Answer$)
END IF
LowerSelectBox
Stat= SetWorkZone(Var_record,Wzone)

GOTO Start


Calc_record:!
LowerSelectBox
Stat= CleanNonVarGrps
Output_script=0
Stat= DisplayMessage("CALCULATING CHANGES")
Stat=OutputAllObjects("tempscript","vedit.d/replacefeatpara",Start_obj,Output_script)
IF Stat=1 THEN Start

LOAD "tempscript"

GOTO Raise_box


Zone_list:!
Group= GrpOfUserProps(WsWorkZoneOrigin,WsWorkZoneOrigin)
IF  GroupCount(Group) THEN
        Namelist$=""
        FOR I=1 TO GroupCount(Group)
                 E1= GroupElement(Group,I)
                 Zone_num= GetUserValue(E1,"Zone number:")
                 if(Zone_num) THEN
                         Descr$= UserDataStr(E1,"Description:")
                         Namelist$= Namelist$&VAL$(Zone_num)&": "&Descr$&","
                 END IF
        NEXT I
        IF LEN(Namelist$) THEN
                Stat= NumericalOrder(Namelist$,",",WsAscending,Namelist2$)
                Stat=GeneralListBox("WORK ZONES","zone selected",Namelist2$)
        END IF
END IF
Stat= DeleteEntity(Group)
RETURN

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