
! script name: hexajet.d/viewtablehtml
! topic: view the contents of an external table in html

!A
!A NAME:
!A
!A 	Html View Table
!A
!A DESCRIPTION:
!A	
!A	Imports a tab separated ascii list of data.
!A	Entries in a row are separated by tabs.
!A	Rows are separated by line feeds.
!A
!B INSTRUCTIONS:
!B
!B 	SELECT EXTERNAL TABLE FILE: Select the table
!B 		to be imported.
!B
!B
!# see also - htdocs/help.d/datatables.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: html view table")

DIM Answer$[256]
DIM A$[256]
DIM B$[256]
DIM Name$[256]
DIM Filename$[256]
DIM Filepath$[256]
DIM Fline$[256]
DIM Field$[256]
DIM Descr$[256]
DIM Destination$[256]
DIM Tab$[32]
DIM Dir$[256]
DIM D_label$[256]
DIM Sub_label$[256]
DIM F_label$[256]
DIM Choice$[256]
DIM Mask$[32]
DIM Drive_letter$[256]
DIM SDevice$[256]
DIM Title$[256]

DEG

Tab$= CHR$(9)


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

Ask_file:!
Filename$=""
Dir$="/usr/weber/database/tables/Hexajet.d/"
D_label$="DIRECTORY"
Sub_label$="SUB DIRECTORIES"
F_label$="FILES"
Choice$="FILE TO OPEN"
Mask$="[A-Za-z0-9]*"
Mask$= "External Table Files (*.*)|*.*||"

Stat=UserFileBox(Dir$,Mask$,D_label$,Sub_label$,F_label$,Choice$)
Stat=SetInputFormat("a99","")
Stat=GetValue("SELECT EXTERNAL TABLE FILE",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$= "CANCEL" THEN Leave
LowerFileBox
Filename$=Answer$
Title$= PathNameFile(Answer$)
IF NamedVarVal("save dirs",WsSystemVars,0) THEN V1=CreateVariable("datatables dir",WsSystemVars,PathNameDirectory(Answer$))


Plotoff
Pc= PointXYZ(0,0,0)
Table1= ImportTable(Filename$,Pc,WsUpperLeft,Tab$)
Stat= DeleteEntity(Pc)
Stat= PlotEntity(Table1)

Sdevice$= System$("MASS STORAGE IS")
N1=POS(Sdevice$,":")
IF N1>1 AND N1<LEN(Sdevice$) THEN
        Drive_letter$=Sdevice$[1,N1-1]
        Sdevice$=Sdevice$[N1+1]
END IF

Backround_color= 6
Table_color= 11
Caption_color= 1
! forces the default values for cell spacing
Cell_spacing= -1
Cell_padding= -1

Filename$= "EXPORT"
Stat= ExportHtmlTable(Table1,Filename$,Title$,Backround_color,Table_color,Caption_color,Cell_spacing,Cell_padding)

SELECT System_id
CASE 1
        Filepath$= " file:"&Filename$&" &"
CASE ELSE
        Filepath$= "file:///"&Drive_letter$&"|"&Filename$
END SELECT
A$ = UniformPathName(Filename$)
Stat = MessageFileBox(A$,"HTML_VIEW","")

Stat= DeleteEntity(Table1)
Leave:!
Stat= DeleteEntity(Pc)
Ploton
LowerFileBox
Stat=SetInputFormat("n4","")
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
