CGI Program Suggestions and Tips
There are a variety of ways to write a given program. The following are some basic steps to make CGI programs more portable and easier to maintain.
Use a single point of entry for CGI applications. Rather than multiple CGI directories with many scripts, a single script to start a single Business BASIC program can be used to determine where to go based on a flag passed through the URL or hidden form fields. The benefits to this method include The startup routine performing the initialization, such as calling utcgi.wbb, creating templates, and loading code tables. Parameterize the script name (using ENV.SCRIPT_NAME$) because all routines use the same script. The application becomes more portable to other sites and platforms that may have a different CGI directory structure.
Use a single point of exit. By using a single exit program, code becomes portable between dynamic and shared-directory methods, as well as other interface methods that may be developed. Ensure that all exits, including error trapping logic, exit through the single routine.
For tracking large volumes of information between CGI programs, store it in a file rather than a URL and hidden field. Instead of many individual fields, assign and track only a session ID. Keep date and time stamps on session records and periodically clear out old ones. If the application supports cookies, use the automatic session tracking support built into BASIC Web Utility 1.1.
HTML can be generated in programs; however, for complex documents, it is often easier to create HTML files. There are a number of HTML editing programs available that function as word processors. The tags needed by uthtmout.wbb and utfrmout.wbb can be embedded in the file, and the file referred to by a single "include" phrase in any uthtm* or utfrm* program:
call "uthtmout.wbb", tpl$, text$, html$, ""