
! script name: vproperty.d/makepropgroup
! var_topic: make a group of info packets

!A
!A NAME:
!A
!A 	Create Packet Group
!A
!A DESCRIPTION:
!A
!A 	This script makes a group of info packets.
!A
!B INSTRUCTIONS:
!B
!B 	GROUP NAME, Autoname: Enter the name of the group or choose "Autoname"
!B 	to name the group automatically.
!B
!B 	INPUT PACKET ID NAME,  Proceed: Select the info packets from the
!B 	selection menu. Select proceed when all the packets that you want
!B 	included in the group have been selected.
!B
!C NOTES:
!C
!C 	Be careful when referencing info packets which may not be present at
!C 	all times.  For Example: Info packets returned by a query may not
!C 	always be present.  You don't want to reference a packet that won't
!C 	be there later.
!C
!# see also - htdocs/help.d/property.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: entity property reference")

DIM Destination$[256]
DIM Answer$[256]
DIM A$[256]
DIM B$[256]
DIM Name$[256]
DIM Element$[256]
DIM Prop_class$[256]
DIM Prop_name$[256]
DIM Class_name$[256]
DIM D_label$[256]
DIM Choice$[256]

Var_object=CheckVarObject
IF ExitScript(Destination$) THEN Leave


Start:!
DeActivateUndo
Start:Stat=SetInputFormat("a99=","",WsFalse)
Stat= SetEqualsValue(0,"A")
Stat=GetValue("GROUP NAME, Autoname ",Name$)
IF ExitScript(Destination$) THEN Leave
IF Name$= "A" OR Name$="a" OR Name$= "Autoname" OR Name$="autoname" THEN
        Auto_name=1
ELSE
        Auto_name=0
END IF

E1= FindNamedGrp(Name$)
IF ValidGeometry(E1) THEN
        Stat=SetInputFormat("a1",",P,")
        Stat=GetValue("NAME IN USE,  Proceed",Answer$)
        IF ExitScript(Destination$) THEN Leave
        IF Answer$="P" THEN Start
END IF


Existing_props:!
Group1= GrpOfUserProps
Group= DependentSubGroup(Group1)
Stat= DeleteEntity(Group1)
IF NOT GroupCount(Group) THEN Leave

Prop_group= CreateGroup(" ")

List_prop:!
IF NOT GroupCount(Group) THEN Make_record
Stat=UserSelectBox("EXISTING INFO PACKETS","Packet selected",0,WsPropGroupSelect,Group)

Pick_prop:!
Stat=SetInputFormat("a99","")
Stat=GetValue("INPUT INFO PACKET ID NAME,  Proceed ",Prop_name$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Prop_name$
CASE "Proceed","P","p","PROCEED","proceed"
        Stat= DeleteEntity(Group)
	GOTO Make_record
CASE "CANCEL"
        Stat= DeleteEntity(Prop_group)
        Stat= DeleteEntity(Group)
        GOTO Leave
END SELECT

Num1= NumericPrefix(Prop_name$)
IF NOT Num1 THEN Pick_prop
Prop_ent= GroupElement(Group,Num1)
IF NOT ValidDependency(Prop_ent) THEN Start
Stat= EntityNameCheck(Prop_ent,Prop_name$)
Stat= AddToGroup(Prop_group,Prop_ent)
Stat=RemoveFromGrp(Group,Num1)
LowerSelectBox
GOTO List_prop


Make_record:!
IF NOT GroupCount(Prop_group) THEN
	Stat= DeleteEntity(Prop_group)
	GOTO Start
END IF
IF Auto_name THEN
	Stat= GenerateVarName(WsGroupEnt,Name$)
END IF
RecordFunctionOn
Stat=RecordDescr("GROUP OF PACKETS :"&Name$)
G1= CreateGroup(Name$,WsGrpOfProperties)
RecordFunctionOff
Num_elements= GroupCount(Prop_group)
FOR I= 1 TO Num_elements
	 E1= GroupElement(Prop_group,I)
         IF ValidGeometry(E1) THEN
         Stat= EntityNameCheck(E1,Answer$)
		RecordFunctionOn
                Stat= AppendToGroup(G1,Answer$)
                RecordFunctionOff
        END IF
NEXT I
RecordFunctionOn
Stat= NameEntity(G1,Name$)
RecordFunctionOff
CloseVarRecord
IF NOT ValidGeometry(G1) THEN
        DelLastVarRecord
	GOTO Start
END IF
Stat= DeleteEntity(Prop_group)
GOTO Start


Leave:!
LowerSelectBox
Stat= DeleteEntity(Group)
Stat= DeleteEntity(Prop_group)
Stat=SetInputFormat("n4","")
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END

