utfrmout.wbb - Merge Template Data Into HTML Form Output


CALL "utfrmout.wbb",tpl$,text$,work$


This high-level program merges BBx data with HTML text and produces a result in work$. The intent is to produce an HTML form with the default handling of data fields as input fields. It is sensitive to the user-defined format attributes in the data template tpl$, as well as format tags in the text$ template. The template attributes are discussed in the Data Templates section.

The HTML text string text$ may contain any text, meta instruction, or field tag reference. It is evaluated and copied, with possible substitutions and insertions, into work$.




Data template that can incorporate user-defined format attributes. For additional information, see the Data Templates section.


Text to be merged.


Text string that returns the HTML version of the form. This form is incomplete as returned and needs a submit button and the <form> </form> HTML tags. It may be necessary to use this feature to build a form from several data templates.

Meta Instructions

{include filename} - loads the text file filename into text$. This method creates HTML template files and incorporates them into an application. filename must be accessible to Business BASIC through a physical path or prefix search.

{if datafield opr value} ... {end} - evaluates the expression datafield opr value. If it fails, it suppresses any text between the if and end tags. If the expression is valid, the tags are removed, but the text between them is retained. datafield can be either a field in the data template or a global string variable name. The operator opr can be >, <, =, >=, <=, <>, in, or !in. The "in" and "!in" operators ("in" or "not in") perform position checks on text fields and values. If datafield is numeric in the template, the value must be a simple number. If datafield is defined with a user attribute of "date=format", the value should be a text date, such as "11/30/95". {if}{end} tags may be nested.

If datafield is not found in the data template and is not a global string variable, the meta instruction is retained in the text.

Note that datafield should not be enclosed by brackets, and there must be at least one space between datafield and opr, and opr and value.

Field Tags

Field tags are placed in text$ in the format [dataname type options].

type is optional, and if not specified, defaults to "text". If dataname is not found in the data template tpl$, and a global string variable is found by that name, it is used as simple text output rather than input.

type can be any of the following words: text, hidden, password, radio, checkbox, memo, list, mlist, show, image, or encode. These are inserted as form input fields in the following formats: text boxes, hidden fields, password input boxes, radio button group, checkbox group, textarea entry, listbox, multi-selection list box, display-only, image tags, and URL-encoded display-only, respectively. URL-encoded display-only format is useful if the insertion is being placed in the middle of a URL link.

The "show" type provides display-only fields in the form.

Radio, checkbox, and list boxes produce groups of selections based on the "keys", "vals", and "sep" options.

Note this regarding image types: unlike uthtmout.wbb, this program does not look for the "image=y" user attribute. Therefore, by default, a form displays the field as a text entry box for maintenance of the data contents. The global string "$imagelib" may be used to specify the physical path to the image files and is prepended to the data from the template to find the image file and calculate pixel dimensions for ".gif" files. Also, the global string "$imageurl" is prepended to the image src tag: <image src=" + STBL("$imageurl") + data-value + ">"

options may include:



sep="char" or $hex$



alt="alternate image description"


The "sep" option defines the separator character in "keys" and "vals". By default, it is a semicolon but may be set to any value, including nonprintable values, except a quote.

The options are used in different ways by the different field input types.

For radio and checkbox groups, "keys" generates the returned value for each group item, and "vals" is used as a caption for each item. In addition, if columns is less than 2, items are positioned vertically. If columns is between 2 and 98, items are placed in a table of the specified number of columns across. If columns is over 98, items are placed horizontally, and the browser breaks the lines in an unpredictable manner.

For list and mlist groups, keys and vals are combined to form each listbox item in the format of "itemn - descn". In addition, if rows is specified, then the list box is defined as the specified number of rows high.

For memo fields, columns and rows is used to define the textarea dimensions. If unspecified, then 60 columns and 15 rows is assumed. Also, the wrap=value adds a wrap option to the textarea tags.

For image tag displays, the alt= option can be used to specify the alternate description browsers use if the image cannot be displayed.