Scrolling Customer Listing - democlst.bbx
This program is used by both sample applications and is the lead program in the Customer Inquiry application in which customers are listed. Each customer has a link to a detailed invoice page. It is also used to select a customer to edit in the Customer Maintenance application.
The program reads up to 10 customer records, in name order, from the customer master file, using key chain 1 (the Name sort key). If additional records are available (there are about 30 in the file), a "More records..." link is provided to continue the list.
|
A CGI variable "startwith" is passed to this program in two cases. If the current execution is a continuation of the list, then the "more records" URL will contain this field In addition, at the bottom of the HTML display is a form with a "startwith" entry field to allow the user to restart the list at any time.
0150 LET STARTWITH$="", STARTWITH$=CVS(FIELD(CGI$,"startwith",ERR=0200),4)
These lines set the values for the uthtmfil.wbb program, identifying the key chain, records per page, and record structure. The HTML template file, democlst.txt, contains a place marker between the "<ul>" and "</ul>" (unordered list) tags. The structure includes a "<li>" (list element) tag so that each record becomes another bullet item in the document. The name field is treated as a link, and the link is specified in the variable LINKEXPR$, which is constructed to run a program with the CGI value, "cust_id", set to the customer number of any given record. The program defaults to the sample invoice list "demoilst.bbx" but can be specified in the CGI value "linkto". The Customer Maintenance application uses the "linkto" value to load and edit a customer record.
|
After opening the customer master file, the uthtmfil.wbb program generates a list of records in the CUSTLIST$ variable and lists up to MAXRECS records. The list starts with the value in STARTWITH$ and continues until the end of the file. If the variable CURKEY$ is returned with a value, the end of the file was not reached, and a "More records" URL is constructed to continue where the list ended. This URL is placed in the global string $MOREURL, which is referenced in the HTML text template democlst.txt.
|
The HTML file, democlst.txt, is loaded and parsed into the variable HTML$. In that file is a comment "<!-- List Here -->", which is substituted with the contents of the CUSTLIST$ variable, generated above. The full text of HTML$ is sent with the utsend.wbb program, and the program exits. In version 1.1, two global string values are created automatically by uthtmfil: $list contains the record list returned in custlist$, and $moreurl contains either null (if the end of file is reached), or a URL to continue the list. These can be referenced in democlst.txt as [$list] and [$moreurl], respectively.
|
It is important to trap all errors because BASIC Web Utility programs run in background mode.
|