
! script name: datatable.d/embedtable
! var_topic: Sample - embedding records

!A
!A NAME:
!A
!A 	LIST Embedding records
!A
!A DESCRIPTION:
!A
!A 	This script gives a list of embeded files in a 
!A 	variational program.
!A
!B INSTRUCTIONS:
!B
!B 	NO HELP AVAILABLE AT THIS TIME
!B
!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
!C NOTE:
!C
!C 	This is an unsupported sample script.
!C

stat=ChangeLabelStr("ScriptNameStatus","Function: list embedings")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]
DIM Descr$[256]
DIM File$[256]
DIM Title$[256]
DIM Search1$[256]
DIM A$[256]

Header_color= 3
Header_ltype= 9
Entry_color= 22
Grid_color= 8

Entry_text_height= GetDefault(WsTextHeight)
Entry_text_width= GetDefault(WsTextWidth)
Head_text_height= 2.0*Entry_text_height
Head_text_width= 2.0*Entry_text_width
Header_slant= TAN(10)

ActivateUndo
Start:!
Search1$= "EMBED:"
group= SearchRecordDescr(Search1$,WsTrue,WsTrue)
IF NOT ValidGeometry(group) THEN Leave

Table1= FindNamedEntity("COMPONENTS TABLE")
IF ValidGeometry(Table1) THEN
        Pc= ParameterPt(Table1,0.0)
        Stat= DeleteEntity(Table1)
ELSE
        Pc= PointXYZ(0.0,0.0,0.0)
END IF

Row_count= GroupCount(group)+1
Nr= Row_count
Nc= 2
Table1= CreateBlankTable(Pc,"COMPONENTS TABLE",Nr,Nc,WsUpperLeft,"  ")
Stat= DeleteEntity(Pc)
Stat= InsertIntoTable(Table1,"Component",1,1)
Stat= InsertIntoTable(Table1,"#",1,2)


Table_pos=2
FOR I= 1 TO GroupCount(group)
	Var_record= GroupElement(group,I)
	stat= GetDescription(Var_record,Descr$)

	group1= SearchRecordDescr(Descr$,WsFalse,WsFalse)
	Ntimes= GroupCount(group1)
	Stat= DeleteEntity(group1)

	N2= POS(Descr$,Search1$)+ LEN(Search1$)
	A$= Descr$[N2]

	Stat= InsertIntoTable(Table1,A$,Table_pos,1)
	Stat= InsertIntoTable(Table1,Ntimes,"integer",Table_pos,2)
	Table_pos= Table_pos+1
NEXT I
Stat= NameEntity(table1,"COMPONENTS TABLE")
Stat= SetTableColors(Table1,0,1,Entry_color)
Stat= SetTableColors(Table1,0,2,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= SetColor(Table1,Grid_color)
Stat= PlotEntity(Table1)

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

Leave:!
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
