uthtmfil.wbb - Generate HTML List from a File, Given a Key Range and Format Definition


CALL "uthtmfil.wbb", chan, first$, last$, keynum, maxrec, count, curkey$, tpl$, text$, work$, linkexpr$


This high-level program simplifies the process of producing an HTML listing of records from a single file, using traditional Business BASIC commands to read the file channel for a specified key range, supporting multi-keyed files through their key chain numbers, and supporting a maximum record count, so that the resulting HTML page size can be controlled.




Channel that the file to be read is opened on and must be opened before CALLing this program.

first$ and last$

Text strings that indicate the key range of records to process. In particular, if the user is to "scroll" through the file, first$ should be set to the value of curkey$ from the last page scrolled through. The program processes all records from first$ forward (whether or not first$ exists as a key in the file) until a record is read with a key greater than last$ + $FF$. If first$ or last$ are null, the records are processed from the first through the last records, respectively. first$ and last$ apply to the key chain specified in keynum.


Key chain number used when processing the file.


Maximum number of records to include in the HTML output.


Returns the actual number of records included in the HTML output.


Returned as null if the end of the file is reached. Otherwise, it contains the value of the key after the last one included in the HTML output. This variable can be used to indicate a starting key value (first$) for the next page in a "scrolling" type of application. Typically, it must be URL encoded before including it in a "more records" URL to continued scrolling. URL encoding is performed by utencode.wbb.


Data template used to read records from the file indicated by chan.


String variable that contains the HTML format for each record, along with embedded data name tags, so that a list format or paragraph breaks are generated between records. For each record, the program "uthtmout.wbb" is CALLed, using this as the format text. See the uthtmout.wbb for additional information.


Returns the HTML text for the records. The global string $list also stores this value and can be used in CALLs to uthtmout.wbb, which can use text containing [$list] to merge the value of work$ automatically.


Text string used by "uthtmout.wbb" to generate any href links from the records to another page. See the uthtmout.wbb for additional information.

Automatic Pagination Support

If the first$ argument is null, the cgi$ variable bbweb_s is checked, and, if present, is used as the starting point for the list. On exit, if more records are available, the program generates a global string (STBL) $moreurl that contains the full URL, with any cgi$ fields retained and with bbweb_s incremented for the next page. This can be used in a hyperlink for a continuation:

{if $moreurl > ""}
<a href="[$moreurl]">More records&ldots;</a>