
! script name: datatable.d/ltasktable
! topic: amo lathe task table

!A
!A NAME:
!A
!A 	Amo Lathe Tasks Table
!A
!A DESCRIPTION:
!A
!A 	Makes a datatable of the list of tools in an amo task list.
!A
!B NOTES:
!B
!B 	This script is a template only. A user may copy and modify
!B 	this script to produce custom charts. Weber systems is not
!B 	responsible for customization of charts for particular needs.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: amo lathe tools table ")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]
DIM Group$[256]
DIM File$[256]
DIM A$[1024]
DIM B$[1024]
DIM Toolid$[256]
DIM Toolmat$[256]
DIM Descr$[256]
DIM Toolname$[256]

ActivateUndo
Units= CurrentUnits

Grid_color= 14

Entry_color= 8
Entry_text_height= GetDefault(WsTextHeight)
Entry_text_width= GetDefault(WsTextWidth)

Header_color= 14
Header_ltype= 9
Head_text_height= 2.0*Entry_text_height
Head_text_width= 2.0*Entry_text_width
Header_slant= TAN(30)

Label_color= 8
Label_ltype= 0
Label_text_height= 1.5*Entry_text_height
Label_text_width= 1.5*Entry_text_width
Label_slant= 0

Tab$= CHR$(9)
Lf$= CHR$(10)

Task_ent=FindUserData("AMO OPERATIONS",WsTaskPacket)
IF ValidGeometry(Task_ent) THEN
	Tool_group=PropGrpFromFields(Task_ent,"Number tools:","Tool ",1,WsToolData)
ELSE
	Tool_group= FindNamedGrp("AMO OPERATIONS")
END IF
IF NOT ValidGeometry(Tool_group) THEN Leave

Nr= GroupCount(Tool_group)+2
Nc= 9
Table1= FindNamedEntity("LATHE AMO TASKS TABLE")
IF ValidGeometry(Table1) THEN
        Stat= EraseEntity(Table1)
        Stat= ReDimTableRows(Table1,Nr)
        Stat= ReDimTableColumns(Table1,Nc)
        Stat= BlankDataTable(Table1)
ELSE
Table_pos:Stat=SetInputFormat("n4","")
        Pc=XyzInput("TABLE LOCATION ",WsXyzInput)
        IF (ExitScript(Destination$)) THEN Leave
        IF NOT ValidGeometry(Pc) THEN Table_pos
        Table1= CreateBlankTable(Pc,"LATHE AMO TASKS TABLE",Nr,Nc,WsUpperLeft,"  ")
        Stat= DeleteEntity(Pc)
END IF

Table_pos=1
Stat= InsertIntoTable(Table1,"Lathe Tasks",Table_pos,2)

Table_pos=2
Stat= InsertIntoTable(Table1,"#",Table_pos,1)
Stat= InsertIntoTable(Table1,"Tool",Table_pos,2)
Stat= InsertIntoTable(Table1,"Tool Type",Table_pos,3)
Stat= InsertIntoTable(Table1,"Tool Nose"&CHR$(10)&"Radius",Table_pos,4)
Stat= InsertIntoTable(Table1,"Insert"&CHR$(10)&"Angle",Table_pos,5)
Stat= InsertIntoTable(Table1,"Inscribed"&CHR$(10)&"Circle",Table_pos,6)
Stat= InsertIntoTable(Table1,"HC Angle",Table_pos,7)
Stat= InsertIntoTable(Table1,"VC Angle",Table_pos,8)
IF Units= WsMetric THEN
	Stat= InsertIntoTable(Table1,"Mmpr",Table_pos,9)
ELSE
	Stat= InsertIntoTable(Table1,"Ipr",Table_pos,9)
END IF

Material= FindUserData("MATERIAL",WsMaterial)
Number= GroupCount(Tool_group)
Table_pos= 3
FOR I= 1 TO Number
	Tool= GroupElement(Tool_group,I)

	Stat=GetUserDataName(Tool,Toolname$)
	Stat=GetUserString(Tool,"Tool type:",Toolid$)


	IF NOT Stat THEN
	   Stat=GetUserString(Tool,"Tool id name:",Toolname$)
	   Stat=GetUserString(Tool,"Tool material:",Toolmat$)
	   Stat=GetUserString(Tool,"Operation description:",Descr$)

	   Tnose_radius=GetUserValue(Tool,"Tool nose radius:")
	   Feed=GetFeedrate(Tool,Material,2)
	   Speed=GetSpeed(Tool,Material)

	   Stat= InsertIntoTable(Table1,I,"integer",Table_pos,1)
	   Stat= InsertIntoTable(Table1,Toolname$,Table_pos,2)
	   Stat= InsertIntoTable(Table1,Toolid$,Table_pos,3)
	   Stat= InsertIntoTable(Table1,Tnose_radius,"decimal 3",Table_pos,4)
	   SELECT Toolid$
	   CASE "OD TURN","ID TURN"
	   	Insert_angle=GetUserValue(Tool,"Insert angle:")
	   	Circle_dia=GetUserValue(Tool,"Inscribed circle:")
	   	HC_angle=GetUserValue(Tool,"Horizontal clearance angle:")
	   	VC_angle=GetUserValue(Tool,"Vertical clearance angle:")

	   	Stat= InsertIntoTable(Table1,Insert_angle,"integer",Table_pos,5)
	   	Stat= InsertIntoTable(Table1,Circle_dia,"decimal 3",Table_pos,6)
	   	Stat= InsertIntoTable(Table1,HC_angle,"integer",Table_pos,7)
	   	Stat= InsertIntoTable(Table1,VC_angle,"integer",Table_pos,8)
	   CASE "OD THREADER","ID THREADER"
	   	Circle_dia=GetUserValue(Tool,"Inscribed Circle Radius:")
	   	HC_angle=GetUserValue(Tool,"Horizontal clearance angle:")
	   	VC_angle=GetUserValue(Tool,"Vertical clearance angle:")

		Stat= InsertIntoTable(Table1,"- na -",Table_pos,5)
	   	Stat= InsertIntoTable(Table1,Circle_dia,"decimal 3",Table_pos,6)
	   	Stat= InsertIntoTable(Table1,HC_angle,"integer",Table_pos,7)
	   	Stat= InsertIntoTable(Table1,VC_angle,"integer",Table_pos,8)
	   CASE ELSE
		Stat= InsertIntoTable(Table1,"- na -",Table_pos,5)
		Stat= InsertIntoTable(Table1,"- na -",Table_pos,6)
		Stat= InsertIntoTable(Table1,"- na -",Table_pos,7)
		Stat= InsertIntoTable(Table1,"- na -",Table_pos,8)
	   END SELECT
	   Stat= InsertIntoTable(Table1,Feed,"decimal 3",Table_pos,9)
	   Table_pos= Table_pos+1

	END IF
NEXT I
Stat= TableTextOrigin(Table1,0,9,WsRightCenter)
Stat= TableTextOrigin(Table1,0,8,WsRightCenter)
Stat= TableTextOrigin(Table1,0,7,WsRightCenter)
Stat= TableTextOrigin(Table1,0,6,WsRightCenter)
Stat= TableTextOrigin(Table1,0,5,WsRightCenter)
Stat= TableTextOrigin(Table1,0,4,WsRightCenter)
Stat= TableTextOrigin(Table1,0,3,WsCenterText)
Stat= TableTextOrigin(Table1,0,2,WsLeftCenter)
Stat= TableTextOrigin(Table1,0,1,WsCenterText)

Stat= SetTableColors(Table1,0,1,Entry_color)
Stat= SetTableColors(Table1,0,2,Entry_color)
Stat= SetTableColors(Table1,0,3,Entry_color)
Stat= SetTableColors(Table1,0,4,Entry_color)
Stat= SetTableColors(Table1,0,5,Entry_color)
Stat= SetTableColors(Table1,0,6,Entry_color)
Stat= SetTableColors(Table1,0,7,Entry_color)
Stat= SetTableColors(Table1,0,8,Entry_color)
Stat= SetTableColors(Table1,0,9,Entry_color)

Stat= TableTextSizes(Table1,1,0,Head_text_width,Head_text_height,Header_slant)
Stat= TableTextOrigin(Table1,1,0,WsCenterText)
Stat= SetTableColors(Table1,1,0,Header_color)
Stat= SetTableLType(Table1,1,0,Header_ltype)

Stat= TableTextSizes(Table1,2,0,Label_text_width,Label_text_height,Label_slant)
Stat= TableTextOrigin(Table1,2,0,WsCenterText)
Stat= SetTableColors(Table1,2,0,Label_color)
Stat= SetTableLType(Table1,2,0,Label_ltype)

Stat= SetColor(Table1,Grid_color)
Stat= PlotEntity(Table1)

Stat= NameEntity(table1,"LATHE AMO TASKS TABLE")

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

Leave:!
IF ValidGeometry(Task_ent) THEN Stat= DeleteEntity(Tool_group)
Stat= DeleteEntity(Pc)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
