
! script name: items.d/parentitemlist
! topic: list all parent item flags

!A
!A NAME:
!A
!A 	List Parent Item Flags
!A
!A DESCRIPTION:
!A
!A 	This script lists all the item flags that are contained within the
!A 	parent item of a selected entity.  This means Synergy will list every
!A 	item flag that is contained within the entity that the flagged
!A 	geometry is part of.
!A
!B INSTRUCTIONS:
!B
!B 	PICK ENTITY: Pick the entity.  This script will list all the item flags
!B 	that are contained in the most senior parent of the entity.
!B
!# see also - htdocs/help.d/items.htm
!# see also - htdocs/help.d/property.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: parent item list ")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]
DIM Class$[256]
DIM A$[256]
DIM B$[256]
DIM File$[256]

File$= "tempdata"
Stat= RemoveFile(File$)
Start:!

Parent_color= 3
Item_color= 4

Pick_entity:!
Stat= SetInputFormat("n4","")
E1=PickEntity("PICK ENTITY")
IF ExitScript(Destination$) THEN Leave

Group1= ParentItemGroup(E1)
IF NOT ValidGeometry(Group1) THEN Start
Stat= PlotEntity(Group1,Parent_color)

Item_Group= EntityItemGroup(Group1)
Stat= DeleteEntity(Group1)
IF NOT ValidGeometry(Item_group) THEN Start

Unique_items= UniqueItemsGrp(Item_group)
IF NOT ValidGeometry(Unique_items) THEN 
	Stat= DeleteEntity(Item_group)
END IF
Stat= AlphabetizePropGrp(Unique_items)

Nitems= GroupCount(Unique_items)
IF Nitems= 0 THEN Leave

stat= OutputString(File$,CHR$(10),WsNewFile)
FOR Item= 1 TO Nitems
        Element= GroupElement(Unique_items,Item)
        Name$= UserDataStr(Element,"Name:")
        Class$= UserDataStr(Element,"Class name:")

        Nitems= SimilarItemsCount(Item_group,Element)
        A$= VAL$(Nitems)&"  "&Class$&" : "&Name$&CHR$(10)
        stat= OutputString(File$,A$,WsAppend)
NEXT Item
stat= OutputString(File$,CHR$(10),WsAppend)
Stat=MessageFileBox(File$,"ITEM LIST")
Stat= DeleteEntity(Item_group)
Stat= DeleteEntity(Unique_items)




GOTO Start

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