/* FinalData tables to HTML konvertor
$VER: 1.00
Author: Steffen Clemenz
E-Mail: clemenz@zedat.fu-berlin.de */
OPTIONS RESULTS
/* ---- Load the rexxsupport library ---- */
IF ( ADDLIB("rexxsupport.library", 0, -30, 0) = FALSE) THEN EXIT 20
IF ( ADDLIB("rexxreqtools.library",0, -30, 0) = FALSE) THEN EXIT 20
/* ---- Tell me the name and place to put the HTML file ----------------- */
file = rtfilerequest("RAM:", , "Path and name of HTML file", ,,)
IF UPPER(RIGHT(file,5))=UPPER(".html") THEN CALL OPEN(out,file,write)
ELSE CALL OPEN(out,file||".html",write)
CALL WRITELN(out,"
")
CALL WRITELN(out,"")
/* ---- Find the address of the processing port. ------------------------ */
/* ---- This will use the first port it can find with the base name. ---- */
FDPortBase = "FINALD."
found = 0
DO p = 1 TO 50
IF ( SHOWLIST('P', FDPortBase || p) ) THEN DO
FDPort = FDPortBase || p
found = 1
LEAVE
END
END
IF ( ~ found ) THEN DO
ShowMessage 1 1 '"Can not find FinalData port!" "" "" "OK" "" ""'
EXIT 10
END
DROP p
DROP found
/* ---- Determine the number of columns and rows in the database. ---- */
ADDRESS VALUE FDPort
NumRows
nrows = RESULT
NumColumns
ncols = RESULT
IF ( nrows = 0 ) THEN DO
ShowMessage 1 1 '"No rows of data in database!" "" "" "OK" "" ""'
EXIT 10
END
IF ( ncols = 0 ) THEN DO
ShowMessage 1 1 '"No columns defined in database!" "" "" "OK" "" ""'
EXIT 10
END
/* ---- Determine which rows and columns will get transferred. ----------- */
/* ---- If selection is OFF or CELL then use all the columns and rows ---- */
firstRow = 1
firstCol = 1
lastRow = nrows
lastCol = ncols
SelectionInfo
PARSE VAR RESULT selType selFrom selTo
SELECT
WHEN ( selType = "COLUMNS" ) THEN DO
firstCol = selFrom
lastCol = selTo
END
WHEN ( selType = "ROWS" ) THEN DO
firstRow = selFrom
lastRow = selTo
END
OTHERWISE DO /* OFF or CELL */
END
END /* end Select */
/* ---- Ask if column names are wanted. If they are, then put them in. ---- */
ADDRESS VALUE FDPort
ShowMessage 1 0 '"Include column names?" "" "" "Yes" "No" ""'
IF ( RESULT = 1 ) THEN DO
ADDRESS VALUE FDPort
data = ""
DO c = firstCol TO lastCol
GetColumnName POSITION c
data = data || "| " ||RESULT || " | "
END /* end column */
CALL WRITELN(out,data||"
")
END
/* ---- For each row of the database, collect the data in each column. ---- */
/* ---- Then type the combined data for the row to the word processor. ---- */
ADDRESS VALUE FDPort
DO r = firstRow TO lastRow
data = ""
ADDRESS VALUE FDPort
DO c = firstCol TO lastCol
CellData c r
data = data || "| " || RESULT || " | "
END /* end column */
CALL WRITELN(out,data||"
")
END /* end row */
ADDRESS VALUE FDPort
/* END OF MACRO FILE */