
! script name: vpkscrews.d/screwdatatable
! var_topic: make a table 

!A
!A NAME:
!A
!A
!A DESCRIPTION:
!A
!A
!B INSTRUCTIONS:
!B
!B 	TABLE LOCATION:  Enter the xy location of the table.
!B
!# see also - htdocs/help.d/property.htm

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

DIM Destination$[256]
DIM Answer$[256]
DIM A$[256]
DIM B$[256]
DIM Name$[256]
DIM Group_name$[256]
DIM D_label$[256]
DIM Choice$[256]

Var_object=CheckVarObject
IF ExitScript(Destination$) THEN Leave

Grid_color= 8
Entry_color= 3
Entry_text_height= 10.0*GetDefault(WsTextHeight)
Entry_text_width= 10.0*GetDefault(WsTextWidth)

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


Start:!
ActivateUndo

Stat=SetInputFormat("a1=",",S,B,")
Stat=SetEqualsValue(0,"S")
Stat=GetValue("SCREW TYPE: Simple, Barrier",Answer$)
IF ExitScript(Destination$) THEN Leave
SELECT Answer$
CASE "B"
        Screw_type= 2
CASE "S"
        Screw_type= 1
END SELECT
`


Make_record:!
Stat= GenerateVarName(WsDataTableEnt,Name$)
RecordFunctionOn
Stat=RecordDescr("TABLE: Extrusion Screw Data")
Stat= SetRecDelLastExec
V1= FreeParameter("X location", 0.0)
V2= FreeParameter("Y location", -1.0*VariableValue("Curr_flight_dia"))
Pc= PointXYZ(V1, V2, 0.0)
Prop_group= GrpOfUserProps
Group= PropertyClassGroup(Prop_group,"Extrusion Screw")
E1= CreateUserData(20010,"Screw",CHR$(10))
Stat= PutUserString(E1,"Class name:","Extrusion Screw")
Stat= PutUserValue(E1,"Class id number:",20010)
Stat= PutUserString(E1,"Name:"," ")
Stat= PutUserString(E1,"Section number:"," ")
Stat= PutUserString(E1,"Section type:"," ")
Stat= PutUserString(E1,"Number of flights:"," ")
Stat= PutUserString(E1,"Screw diameter:"," ")
Stat= PutUserString(E1,"Section length:"," ")
Stat= PutUserString(E1,"Start pitch:"," ")
Stat= PutUserString(E1,"End pitch:"," ")
Stat= PutUserString(E1,"Start flight width:"," ")
Stat= PutUserString(E1,"End flight width:"," ")
Stat= PutUserString(E1,"Start channel depth:"," ")
Stat= PutUserString(E1,"End channel depth:"," ")
Stat= PutUserString(E1,"Start leading radius:"," ")
Stat= PutUserString(E1,"End leading radius:"," ")
Stat= PutUserString(E1,"Start trailing radius:"," ")
Stat= PutUserString(E1,"End trailing radius:"," ")
IF Screw_type=2 THEN
	Stat= PutUserString(E1,"Start barrier flight diameter:"," ")
	Stat= PutUserString(E1,"End barrier flight diameter:"," ")
	Stat= PutUserString(E1,"Start barrier flight width:"," ")
	Stat= PutUserString(E1,"End barrier flight width:"," ")
	Stat= PutUserString(E1,"Start melt channel width:"," ")
	Stat= PutUserString(E1,"End melt channel width:"," ")
	Stat= PutUserString(E1,"Start melt channel depth:"," ")
	Stat= PutUserString(E1,"End melt channel depth:"," ")
END IF
Stat= InsertIntoGrp(Group,E1,1)
V2= FreeParameter("Table origin",WsUpperLeft)
Table1= TableFromPropGrp(Group,Pc,":",V2)
Stat= DeleteTableRow(Table1,2)
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)
Stat= Transposetable(Table1)
Stat= DeleteEntity(E1)
Stat= DeleteEntity(Group)
Stat= DeleteEntity(Prop_group)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(Table1) THEN
        !DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("screw data table")
	Stat= AddItemToUndo(WsUBCreateMode,Table1)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
	Stat= PlotEntity(Table1)
END IF


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


