CDW000

Build HTML Table

Last Revised: 10/03/17

This program is used to create an HTML table.  An HTML table is a representation of data in a grid with rows and columns.

CALL "CDW000", HTML$, OPT$, TRD$, { CHAN }

CDW000
HTML$ To/From CDW000 appends data to HTML$ as the table is built.
OPT$ To pass OPT$ to CDW000 with tag and attribute values (see table below)
TRD$ To pass TRD$ to CDW000 with the current table, row, or cell contents to be added to HTML$.  It will be cleared by CDW000, so the calling routine does not have to, except for table data (cell) type calls.  See examples.
CHAN To optionally passed to CDW000 as a channel number for a string file used to store the resultant html.  If a non-zero value is passed to CDW000, then the html text will be written to the CHAN at the end of a row when the table reaches 10,000 characters.  Note that when passing CHAN, the calling application must call CDW000 at the start of a table using the 't' OPT$ and at the end of the table using the 'c' OPT$.  When not passing CHAN, the application must call CDW00 at the end of the table using the 't' OPT$.

The first character of OPT$ indicates the tag to be created:

t table (excludes closing tag when CHAN is passed)
c table close only, when CHAN is passed
r table row
d table data (cell)
h table data (header cell)
f font

The following characters of OPT$ indicate the attributes of the tag. The table below lists which attributes are valid for each tag.

Attribute Description Table Row Data Font Note
b bold N N Y N b means bold for table data,
bxx border Y N N N borders for the table tag

Note: b with no following number assumes a value of 1
Note: b- will collapse the border with a value of 1

u underline N N Y N  
i italic N N Y N  
l left Y Y Y N horizontal alignment of text within cells, or table within page
c center Y Y Y N
r right Y Y Y N
t top N N Y N vertical alignment of text within cells
m middle N N Y N
o bottom N N Y N
hx heading tag N N Y N x can be 1 - 6, i.e., <h1> thru <h6>
gxxxxxx background color Y Y Y Y xxxxxx is the RGB pairs
xxxxxx must be exactly 6 characters
fxxxxxx text color N N Y Y
n no wrap N N Y N prevents the text from wrapping to multiple rows except when <br> is used
wxxxx width Y N Y N xxxx can be 1 to 4 characters long and indicates pixels as in 50 or percentage as in 100%
sxx columns to span N N Y N s means colspan for table data
  cell spacing Y N N N cell spacing for table tag

Note that an s with no number following assumes a value of 1

pxx cell padding Y N N N p without a following number assumes a value of 3
zxx font size N N Y Y xx can be 1 thru 6,
+1 thru +6,
-1 thru -6
a Header cell N N Y N uses <th> tag instead of <td> to inherit stylesheet attributes
blank custom Y Y Y Y adds custom attributes to the tag that follow the blank, i.e., "d class='sale'" or "r style='

Note that CDW000 can be used with and without cascading style sheets.  It is always preferred to use a style sheet as opposed to hard coding the colors, font and border styles, etc. in the bbx program, as a single change to the style sheet can be easily made without changing each bbx program.

In order to create tables with rows of alternating background text colors, CDW000 will assign class='rowodd' to odd numbered rows, and class='roweven' to even numbered rows in the table.  You can disable this by setting global "WMS_CDW000_RC" to null once before calling CDW000 for the first time, i.e., TMP$=STBL("WMS_CDW000_RC","").

As of this writing, some email clients including Google Mail and Hotmail do not support <style> tags within the email.  They do, however, support inline styles as attributes within a tag, such as <td style='background-color:#eeeeee'>.  Set the first character of global WMS_CDW000 to "D" indicating to create a Dynamo Standard format using inline styles.  This will make the table larger, but will be supported by all email clients and web browsers.

Dynamo Standard Table

tag

style will include
<table> border-collapse:collapse
<td> border:1px solid #c0c0c0;padding:1px 3px 1px 3px
<th> border:1px solid #c0c0c0;padding:1px 3px 1px 3px;font-weight:normal;text-align:left
<tr>
heading row background-color:#ffff99; vertical-align:top
odd numbered row background-color:#ffffff; vertical-align:top
even numbered row background-color:#eeeeee; vertical-align:top

Click here for a good example of popular html colors by color# and name that are supported by all browsers.

Example of a sub-routine to create HTML tables for a bill to address, ship to address, and invoice heading fields.
1000 EXAMPLE:
1010 ROW$="",TAB$="",HTML$=""
1020 CALL "CDW000", ROW$, "db", "Bill To"
1030 CALL "CDW000", ROW$, "db", "Ship To"
1040 CALL "CDW000", TAB$, "rgccffcc", ROW$


1050 CALL "CDW000", ROW$, "dt", "Excellware, Inc<br>PO Box 33114<br>North Royalton, OH  44133"
1060 CALL "CDW000", ROW$, "dt", "Excellware, Inc<br>Attn: Len Krause<br>8050 Corporate Cir STE 1<br>North Royalton, OH  44134"
1070 CALL "CDW000", TAB$, "r", ROW$

1080 CALL "CDW000", HTML$, "tbp", TAB$

1085 HTML$=HTML$+"<br>"

1090 CALL "CDW000", ROW$, "dbc", "Your PO#"
1100 CALL "CDW000", ROW$, "dbc", "Invoice#"
1110 CALL "CDW000", ROW$, "dbc", "Invoice Date"
1120 CALL "CDW000", ROW$, "dbc", "Terms of Sale"
1130 CALL "CDW000", ROW$, "dbc", "Due Date"
1140 CALL "CDW000", TAB$, "rgccffcc", ROW$

1150 CALL "CDW000", ROW$, "dc", "8812345"
1160 CALL "CDW000", ROW$, "dc", "7045"
1170 CALL "CDW000", ROW$, "dc", "03/04/07"
1180 CALL "CDW000", ROW$, "dc", "Net 20 Days"
1190 CALL "CDW000", ROW$, "dc", "03/24/07"
1200 CALL "CDW000", TAB$, "r", ROW$

1210 CALL "CDW000", HTML$, "tbp", TAB$
1220 RETURN

Bill To Ship To
Excellware, Inc
PO Box 33114
North Royalton, OH 44133
Excellware, Inc
Attn: Len Krause
8050 Corporate Cir STE 1
North Royalton, OH 44134
Your PO# Invoice# Invoice Date Terms of Sale Due Date
8812345 7045 03/04/07 Net 20 Days 03/24/07

Note that since this document uses a cascading style sheet, the wider top border, border style and color were determined by the style sheet and not by CDW000.

Email Example
To email the above data, with no operator intervention, you would open the printer using CDS084 and print HTML$ to the printer channel.  If operator intervention is required, to enter 'cover page text' for example, then omit S084.MODE$="E".
0100 REM "Example emailing CDW000 output
0110 BEGIN
0120 CALL "CDS091",Y$
0130 GOSUB EXAMPLE
0140 CALL "CDS041","CDS084",S084$
0150 LET S084.NAME$="MAIL",S084.EMAILTYPE$="H",S084.MODE$="E"
0160 LET S084.TOEMAIL$="len@excellware.com"
0170 LET S084.TONAME$="Len Krause"
0180 LET S084.TOCOMP$="Excellware, Inc."
0190 CALL "CDS084",ERR=EOJ,Y$,Y5$,U0,S084$,Y6,Y6$
0200 PRINT (Y6.CH)HTML$
0210 GOTO EOJ