
! script name: property.d/makeproptable
! topic: make a table from a packet class directory

!A
!A NAME:
!A
!A 	Make Property Table
!A
!A DESCRIPTION:
!A
!A 	This script makes a table from an info packet class directory.
!A	You can use the table as a visual display of the information
!A 	contained in the info packet, or you can export the table so that
!A 	the data can be used by a program outside of Synergy. 
!A
!B INSTRUCTIONS:
!B
!B 	PACKET CLASS DIRECTORY: Select the packet directory that
!B 	you wish to make a table from.
!B
!B 	TABLE LOCATION:  Enter the xy location of the table.
!B
!# see also - property.d/property.hlp

Stat=ChangeLabelStr("ScriptNameStatus","Function: make info packet table")

DIM Destination$[512]
DIM Answer$[512]
DIM A$[512]
DIM B$[512]
DIM Name$[512]
DIM Prop_dir$[512]
DIM Prop_class$[512]
DIM Class_dir$[512]
DIM Filename$[512]
DIM Class_name$[512]
DIM Namelist$[32000]
DIM Filelist$[32000]
DIM D_label$[512]
DIM Choice$[512]
DIM Current_dir$[512]
DIM Ques$[512]

Stat= NamedVarStr("properties dir",WsSystemVars,"/usr/weber/database/properties/",Prop_dir$)

ActivateUndo
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:!
D_label$="PACKET CLASSES"
Choice$="CLASS SELECTED"
Ques$= "PACKET CLASS DIRECTORY"
Answer$= SelectDirectory(Prop_dir$,"*",Ques$,D_label$,Choice$,"",Current_dir$)
IF (ExitScript(Destination$)) THEN Leave
IF  Answer$= "CANCEL" THEN Leave
Answer$= TRIM$(Answer$)
Class_dir$= Answer$
Prop_class$=  BaseNamePath(Class_dir$,Prop_dir$)

Table_pos:Stat=SetInputFormat("n4","")
Pc=XyzInput("TABLE LOCATION ",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pc) THEN Table_pos

Table1= TableFromPropDir(Class_dir$,Pc,":",WsUpperLeft,WsAscending)
Table2= CreateBlankTable(Pc,"",4,2,WsLowerLeft,"    ")
Stat= DeleteEntity(Pc)

Set_table_props:!
Stat= TableTextOrigin(Table1,1,0,WsCenterText)
Stat= SetTableColors(Table1,0,0,Entry_color)
Stat= SetTableColors(Table1,1,0,Header_color)
Stat= TableTextSizes(Table1,1,0,Head_text_width,Head_text_height,Header_slant)
Stat= SetColor(Table1,Grid_color)

Stat=InsertIntoTable(Table2,"Directory",1,1)
Stat=InsertIntoTable(Table2,"Storage",2,1)
Stat=InsertIntoTable(Table2,"Class name",3,1)
Stat=InsertIntoTable(Table2,"Class id",4,1)

Namelist$= DirectoryNamesStr(Class_dir$,"*")
Stat= StringFieldStr(Namelist$,",",1,Answer$)
Stat= GetExtUserString(FileNameString(Class_dir$,Answer$),"Class name:",Class_name$)
Id_number= GetExtUserValue(FileNameString(Class_dir$,Answer$),"Class id number:")

Stat=InsertIntoTable(Table2,Prop_class$,1,2)
Stat=InsertIntoTable(Table2,"Delete",2,2)
Stat=InsertIntoTable(Table2,Class_name$,3,2)
Stat=InsertIntoTable(Table2,VAL$(Id_number),4,2)

Stat= PlotEntity(Table1)
Stat= PlotEntity(Table2)

ActivateUndo
Stat= AdvanceUndoNumber("property table")
Stat= AddItemToUndo(WsUBCreateMode,Table1)

GOTO Start

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


