Startup Program - demobbw.bbx
This program is started by the demobbw.sh shell script. It loads the CGI environment with a CALL to "utcgi.wbb" and creates the data templates used by the other sample programs.
0010 REM "demobbw.bbx - startup for BASIC Web Utility demo programs
0020 REM "Copyright 1996 by Allen Miglore. All rights reserved.
0100 REM ^100 - Introduction
0110 REM "This is the startup routine used by the BASIC Web Utility demo
0120 REM "program. It reads the CGI input stream, sets up the
0130 REM "data templates, loads a salesperson code table, and then runs
0140 REM "a specified program. The default program is a customer list.
0200 REM ^100 - get cgi inputs
0210 CALL "utaddr.wbb"
0220 CALL "utcgi.wbb",ENV$,CGI$,ERRMSG$;
IF ERRMSG$>""
THEN
GOTO LOADERROR
0300 REM ^100 Dim templates used by the files
0310 DIM CUST$:"cust_id:c(5*),
name:c(30*):case=upper:,
addr1:c(30):caption=Address_1 case=upper:, addr2:c(30*):caption=Address_2 case=upper:,
city:c(20*):case=upper:,
state:c(2*):case=upper:,
zip:c(5*),
phone:c(10*):mask=(000)-000-0000:,
date_last_sale:c(8):date=yymd:,
date_last_pmt:c(8*):date=yymd:,
class:c(2),
slsp:c(3):keys={stbl_$SLSPID} vals={stbl_$SLSPNM} sep=\\\ formtype=list rows=1:,
terms:c(2*),
credit_limit:n(8*):mask=###,##0-:,
ytd_sales:n(10*):mask=###,##0.00-:,
mtd_sales:n(10*):mask=###,##0.00-:,
ytd_cost:n(10*):mask=###,##0.00-:,
mtd_cost:n(10*):mask=###,##0.00-:"
0320 DIM INVOICE$:"cust_id:c(5),
invoice:c(5),
date:n(8):date=jul:,
slsp:c(3),
fill:c(2):formtype=hidden:,
amount:i(4):scale=2 mask=###,##0.00-:"
0330 DIM SLSP$:"slsp_id:c(3*),name:c(20*)"
In the CUST$ data template, a list of keys and descriptions are referred to by the global string values $SLSPID and $SLSPNM. These lists are loaded here, and when other routines generate selection lists or displays of salesperson values, the ID's and names are used.
0400 REM ^100 - load the STBL's for $SLSPID and $SLSPNM
0410 REM "The CUST$ template references keys and vals for the slsp field.
0420 REM "This facilitates the default use of a select list object for
0430 REM "entry forms, and also will cause HTML merges to use the name
0440 REM "rather than the id for display purposes. Note that placing
0450 REM "these references in the template merely serves to provide
0460 REM "default formatting, and that can be overridden in any given
0470 REM "situation.
0480 LET SLSPCHAN=UNT;
OPEN (SLSPCHAN)"GENSMPL2"
0490 LET IDS$="",NAMES$=""
0500 READ RECORD(SLSPCHAN,END=0520)SLSP$
0510 LET IDS$=IDS$+SLSP.SLSP_ID$+"\\\",NAMES$=NAMES$+SLSP.NAME$+"\\\";
GOTO 0500
0520 LET X$=STBL("$SLSPID",IDS$),X$=STBL("$SLSPNM",NAMES$),IDS$="",NAMES$=""
0530 CLOSE (SLSPCHAN)
Now that the setup is complete, the program branches to the program specified in the CGI input value "pgm". If no pgm value is specified, or an invalid pgm is specified, the HTML document "demomenu.txt" is loaded and displayed. By using the text "{include filename}" and calling "utmeta.wbb", a disk-based document can be loaded.
0600 REM ^100 - Run the program specified in pgm, or default to the menu.
0610 RUN FIELD(CGI$,"pgm",ERR=0620),ERR=0620
0620 LET TEXT$="{include demomenu.txt}"
0630 CALL "utmeta.wbb","",TEXT$
0640 CALL "utsend.wbb",TEXT$
0650 DONE:
RELEASE
1000 LOADERROR:
REM ^1000 - problem with utcgi - fatal problem
1010 REM "If we are here, there was a REAL BIG PROBLEM. Without
1020 REM "proper initialization, the DOS/WIN environment has no way
1030 REM "of contacting the browser of this, so the best thing is
1040 REM "just to leave gracefully but silently. On UNIX, with
1050 REM "stdout support, a notification of the error can be sent
1060 REM "to the browser.
1070 IF POS("DOS"=INFO(0,0))>0 OR POS("WIN"=INFO(0,0))>0
THEN
GOTO DONE
1080 PRINT "Content-type: text/html",$0A$
1090 PRINT "The following error message was returned by utcgi.wbb:<br>"
1100 PRINT ERRMSG$
1110 GOTO DONE