
! script name: property.d/deleteprop
! topic: delete an info packet and remove its associations

!A NAME:
!A
!A 	Delete Property
!A
!A DESCRIPTION:
!A
!A 	This script deletes an info packet from a Synergy file and removes
!A 	its entity associations.  Delete info packets after they have 
!A 	outlived their usefulness.
!A
!B INSTRUCTIONS:
!B
!B 	From the packet menu, mark the info packets that you are deleting.
!B 	The packets are deleted after you select "DELETE."  When the info
!B 	packet is deleted, Synergy will remove all references to that packet
!B 	from its entities.
!B
!# see also - htdocs/help.d/property.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: delete an info packet ")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]
DIM A$[256]
DIM B$[256]
DIM List$[32000]


DeActivateUndo
Start:!
Delete_group= CreateGroup("")
Group= GrpOfUserProps
IF NOT GroupCount(Group) THEN Leave

Pick_prop:!
List$=""
FOR I=1 TO GroupCount(Group)
	E1= GroupElement(Group,I)
	A$= UserDataStr(E1,"Class name:")
	B$= UserDataStr(E1,"Name:")
	N1= ElementGrpNum(Delete_group,E1)
	IF N1 THEN
		List$= List$&VAL$(I)&") deleted   "&A$&":  "&B$&","
	ELSE
		List$= List$&VAL$(I)&")  "&A$&":  "&B$&","
	END IF
NEXT I
Stat=GeneralListBox("INFO PACKETS","Packet selected",List$)

Stat=SetInputFormat("a99","")
Stat=GetValue("SELECT PACKET, Undo, Cancel, Delete ",Name$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Name$
CASE "CANCEL"
	GOTO Leave
CASE "Delete", "D", "d", "delete"
	GOSUB Delete_props
	GOTO Start
CASE "Cancel", "C", "c", "cancel"
	Stat= DeleteEntity(Delete_group)
	Stat= DeleteEntity(Group)
	GOTO Start
CASE "Undo","U","u","undo"
	N1= GroupCount(Delete_group)
	Stat=RemoveFromGrp(Delete_group,N1)
	GOTO Pick_prop
END SELECT

Num1= NumericPrefix(Name$)
IF NOT Num1 THEN Pick_prop
Prop_ent= GroupElement(Group,Num1)
IF NOT ValidGeometry(Prop_ent) THEN Pick_prop

N1= ElementGrpNum(Delete_group,Prop_ent)
IF NOT N1 THEN
	Stat= AddToGroup(Delete_group,Prop_ent)
END IF
GOTO Pick_prop


Delete_props:!
FOR I= 1 TO GroupCount(Delete_group) 
	Prop_ent= GroupElement(Delete_group,I)
	Id_number=GetUserValue(Prop_ent,"Class id number:")
	Stat= UnAssocUserData(Prop_ent,Id_number)
	Stat= DeleteEntity(Prop_ent)
NEXT I
Stat= DeleteEntity(Delete_group)
Stat= DeleteEntity(Group)
RETURN

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

