
! script name: vproperty.d/propgrouptable
! var_topic: make a table from a single info packet

!A
!A NAME:
!A
!A 	Packet Table
!A
!A DESCRIPTION:
!A
!A 	This script makes a table from a single info packet. This allows you
!A 	to make practical use of the data that resides in an info packet.  The
!A 	data in the table can be displayed, manipulated, or imported and
!A 	exported.
!A
!B INSTRUCTIONS:
!B
!B 	SELECT PACKET: Select the packet that you wish to make a table from.
!B
!B 	TABLE LOCATION:  Enter the xy location of the table.
!B
!# see also - htdocs/help.d/property.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: make single property table")

DIM Destination$[256]
DIM Answer$[256]
DIM A$[256]
DIM B$[256]
DIM Name$[256]
DIM Namelist$[32000]
DIM Prop_name$[256]
DIM Point$[256]
DIM D_label$[256]
DIM Choice$[256]

Var_object=CheckVarObject
IF ExitScript(Destination$) THEN Leave

Grid_color= 18
Entry_color= 12
Entry_text_height= GetDefault(WsTextHeight)
Entry_text_width= GetDefault(WsTextWidth)

Header_color= 17
Head_text_height= 1.2*Entry_text_height
Head_text_width= 1.2*Entry_text_width
Header_slant= TAN(20)

Start:!
ActivateUndo
Existing_props:!
Namelist$=""
Group1= GrpOfUserProps
Group= DependentSubGroup(Group1)
Stat= DeleteEntity(Group1)
IF NOT GroupCount(Group) THEN Leave
Stat=UserSelectBox("EXISTING INFO PACKETS","Packet selected",0,WsPropGroupSelect,Group)

Pick_prop:!
Stat=SetInputFormat("a99","")
Stat=GetValue("INPUT INFO PACKET ID NAME",Name$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Name$
CASE "CANCEL"
        Stat= DeleteEntity(Group)
        GOTO Leave
END SELECT

Num1= NumericPrefix(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= DeleteEntity(Group)
LowerSelectBox

Center_point:stat= SetInputFormat("n4","")
E1=PickEntity("TABLE LOCATION")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Center_point
Stat= EntityNameCheck(E1,Point$)
T1= LastPickPara
Pick_return1= CurrPickReturn
Pc= ParameterReturnPt(E1,T1,Pick_return1)
Stat=SetLastPoint(Pc)
Stat= DeleteEntity(Pc)

Make_record:!
Stat= GenerateVarName(WsDataTableEnt,Name$)
RecordFunctionOn
Stat=RecordDescr("TABLE: Property ")
SELECT Pick_return1
CASE WsGeometryEnd
        Pc= ParameterReturnPt(Point$,T1,WsGeometryEnd)
CASE WsGeometryMid
        Pc= ParameterReturnPt(Point$,T1,WsGeometryMid)
CASE WsGeomCenter
        Pc= ParameterReturnPt(Point$,T1,WsGeomCenter)
END SELECT
V1= StringConstant(":")
V2= FreeParameter("Table origin",WsUpperLeft)
Table1= TableFromPropGrp(Prop_name$,Pc,V1,V2)
Stat= NameEntity(Table1,Name$)
Stat= DeleteEntity(Pc)
V1= FreeParameter("Entry color",Entry_color)
V2= FreeParameter("Entry text width",Entry_text_width)
V3= FreeParameter("Entry text height",Entry_text_height)
V4= FreeParameter("Entry text slant",Entry_slant)
Stat= SetTableColors(Table1,0,0,V1)
Stat= TableTextSizes(Table1,0,0,V2,V3,V4)
V1= FreeParameter("Header color",Header_color)
V2= FreeParameter("Header text width",Head_text_width)
V3= FreeParameter("Header text height",Head_text_height)
V4= FreeParameter("Header text slant",Header_slant)
V6= FreeParameter("Grid color",Grid_color)
Stat= SetTableColors(Table1,1,0,V1)
Stat= TableTextSizes(Table1,1,0,V2,V3,V4)
Stat= SetColor(Table1,V6)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(Table1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("property table")
	Stat= AddItemToUndo(WsUBCreateMode,Table1)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
	Stat= PlotEntity(Table1)
END IF

GOTO Start

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


