COLDEF

Top  Previous  Next

COLDEF

 

Syntax

 

1.[ coldef | ccoldef ] col, cols, options
{ code block }
 
2.coldef "text | ~regexpr", coloffset, cols, options
{ code block }
 
3.coldef "text | ~regexpr", coloffset, "to-text | ~to-regexpr", to-coloffset options
{ code block }

 

Syntax 1 defines an absolute column region. coldef 30,21 for example, would define a column region from column 30 for 21 columns (30-50).  If the "ccoldef" syntax is used, then col is the starting column, and cols is the ending column. ccoldef 30,50 would define the same region as above.

 

Syntax 2 defines a region based on a search for a starting point.  For each text value or regexpr (regular expression) found, the region will begin at the column coloffset from the point found, and extend for cols columns.  For example, coldef "Customer total",-1,52 will create the region from 1 column before the occurrence of "Customer total", and extend the region for 52 columns.

 

Syntax 3 defines the region based on two searches, one to find the starting column, one to find the ending column to the right of the starting point.  In both cases, the column position is adjusted for the offset. coldef "Current",-1,"30-Days",-1 would define a region starting one column before the word "Current", extending to one column before the word "30-Days".  If just the first string is found, then all columns from there to the last are specified.  If just the last string is found, then all columns from the first through there are specified.  For this reason, be sure that any absolute column regions are specified first.

 

Description

 

Column definitions are used to define columns within a row definition.  Each column definition becomes a table cell (<td>…</td>), with each row in the column being separated by a line break (<br>).  There can be up to 255 column definitions within any given row definition.  Any given column will be formatted based on the first coldef keyword that applies to it.  Columns not so defined will be displayed as mono-spaced text, using the HTML <pre> and </pre> tags.

 

Each column definition can define attributes that will apply to the text and cell formatting, and optionally can have a code block associated with it to add custom Business Basic coding to the data in the column.

 

Options are comma-separated lists of words and parameters.  The options available in the column definition include:

 

Option

How it gets applied

bgcolor=#rgb, bgcolor=color

Cell gets a bgcolor=value attribute to control the background color. The color can be expressed as an #rrggbb hexadecimal value or as a color name supported by the target browser, such as red, blue, white, etc..

blink

Text gets <blink> attribute.

bold

Text gets <b> attribute.

bottom, top, middle

Cell gets "valign=value" attribute to control vertical justification.  The default is "top".

center, left, right

Cell gets "align=value" attribute to control horizontal justification.  The default is "left".

color=#rgb, color=color

Text gets <font color=value> attribute.  The color can be expressed as a #rrggbb hexadecimal value or as a color name supported by the target browser, such as red, blue, white, etc..

font=font

Text gets <font face=font> attribute.  Several modern browsers support this, though the font typeface selected may not be available on all clients.

hdr=html text

The top of the column gets the html text, followed by a line break <br> tag.  Use this option to replace top of page column headers with "in cell" column headers.

hdron=hdron text

hdroff=hdroff text

hdrtd=hdrtd text

The column header, if defined with hdr, gets these values in its <td hdrtd>hdron hdr value hdroff</td> structure.  Be sure to turn off any hdron text HTML tags in hdroff text.

italic

Text gets <i> attribute.

image

Text is assumed to be file names that are image files, and gets treated as an <img> tag.  The ufparam.txc|t file values for imagelib and imageurl are used for image processing.  The imagelib value is used to locate files on the web server's file system in order to calculate width and height values (.gif and .jpg files only.)  The imageurl value is prefixed to the report data when constructing the <img src="image URL">.

ltrim, rtrim, trim

These three mutually exclusive options will cause UnForm to left, right, or left and right trim the text of the column when generating the HTML cell text.  By default, any spaces in the data for the cell remain in the output.  Use of this option may save some disk storage space and document transmission time.

noencode

If this option is present, then the text is not encoded for HTML markup entities.  This should only be used if you know that the text contains valid HTML coding.

otheropt=options

The table cell gets additional attributes not otherwise specified by the other options.

size=n

Text gets <font size=n> attribute.  Size ranges from 1 to 7, with 3 being considered a "normal" size.

suppress

If this word is present, then column data gets set to null.

underline

Text gets <u> attribute.

 

 

Code blocks are optional definitions associated with any given column definition.  With a code block, it is possible to manipulate the text of each row in the column.  A typical use of this capability might be to convert the plain text to hyperlinks, so that a column of part numbers could be linked to pages in a catalog, for example.  Code blocks begin just after the opening brace "{", can extend as many lines as required, and end with a closing brace "}".

 

The code block is executed for each row of the column.  As the code starts, the following variables can be used:

 

Variable

Description

attr.align$

attr.bgcolor$

attr.blink

attr.bold

attr.color$

attr.font$

attr.italic

attr.otheropt$

attr.size$

attr.underline

attr.valign$

The attr$ variable is a string template that defines the attributes to apply to the text or cell.  These values match those defined above in the Options.  Numeric values can be set to 0 (false) or 1 (true).  String values can be set to any valid value for that attribute.

colofs

The column offset from the left edge of the text.  If the column region is from column 21 through 40, then colofs will be 21.  This should be treated as a read-only value.

cols

The number of columns in the region.  Read only.

row

The row number within the current region, from 1 through the last row in the region.  With each execution of the subroutine, the row will increase by 1.  Read only.

row$

The text of the current row within the region.  This can be manipulated by the code.

rowofs

The position of the current row, relative to the whole page.  If you need to refer to data in some other column of the current row, use rowofs.  Read-only.

 

Functions available for your use, in addition to any intrinsic Business Basic functions, include:

 

Function

Description

get(col,row,cols)

Returns text from the page, given the column, row, and cols parameters.

htmencode(text$)

Returns text$ after converting HTML entities into displayable versions.

set(col,row,cols,text$)

Sets text$ into the page at the given column, row, and columns.

urlencode(text$)

Returns text$ after URL encoding to make it suitable for inclusion in a hyperlink.