This chapter introduces the BASIC interpreter NLM and describes
For information on creating BASIC scripts in NetBasic, see NetBasic for Internet.
The BASIC interpreter is an NLM that uses RCGI to receive request data, invoke a script, pass the request data to the script, interpret the script's output, and return the generated web pages to the NetWare® Web Server to transmit to the client.
Click here to view the relationship of the BASIC interpreter and the NetWare Web Server
The BASIC interpreter must be loaded for BASIC scripts to be interpreted. To load the interpreter, type
LOAD BASIC
The interpreter uses the default port identified by the RemoteScriptAlias directive in the SRM.CFG file as described in Configuring the NetWare Web Server. By default, the directive identifies port 8001 when the Web Server is installed. If you want the interpreter to use a different port, modify the RemoteScriptAlias directive to use another port.
The BASIC interpreter NLM implements Dartmouth BASIC with some limitations and extensions.
If an error occurs while a BASIC script is executing and no error trapping has been set up, interpretation of the script stops and the RCGI connection is terminated.
Before you write a BASIC script that will generate dynamic Web pages, you should
If you need detailed information about the BASIC language, consult a text that describes Dartmouth BASIC.
The Web Server includes a sample script that shows how to use BASIC to generate a dynamic Web page. The sample script is stored in the file \WEB\SCRIPTS\CARDSAMP.BAS. Example 1 also shows this script; click here to view the example.
The script outputs two web pages: a static web page that allows the user to select one of several options and a dynamic web page generated on the basis of the user's selection.
The script implements a web page that offers users a choice of several greeting cards- a birthday card, an anniversary card, or a thank-you card-and asks users to specify their name and the name of the card's recipient. When the user chooses a card and enters the names, the server returns a new web page showing the chosen card and a personalized greeting. Such a script needs to accomplish the following:
The following sections describe the BASIC statements that perform these functions.
The first step is to print a header. The script therefore begins with a statement that adds a field that defines the returned document as an HTML document to the HTML header. The statement is
11 print `Content-type: text/html` : print
The next part of the script returns the web page that allows the user to choose a greeting card and specify sender and recipient names. The statement
12 if argc$ <> "0" then 510
determines how many arguments were sent by the browser. If the argument count is zero, the script moves on to line 15. Lines 15-500 return an HTML page that lists the greeting card options and allows users to specify their choices. Click here to view lines 15 through 500 of the script.
If the number of arguments received by the script is not zero, the script jumps to line 510. Line 510 points to later sections of the script, which output the HTML code for the greeting card chosen by the user.
510 on val(form$(query_string$, "type")) goto 1000,2000,3000
The QueryString environment variable contains the argument values in pairs (argument name-argument value). Line 510 calls the form$ function, which retrieves named arguments from the query string. Thus, the function call
form$(query_string$, "type")
returns the value of type, which in this case specifies the kind of card requested. For type=1, the script jumps to line 1000 and prints a birthday card. For type=2, the script jumps to line 2000 and prints an anniversary card. For any other value, the script jumps to line 3000 and prints a thank you card.
The form$ function is used later in the script (lines 1005, 1800, 2010, 2800, 3005, and 3110) to retrieve the names of the sender and recipient of the card from the query string. (The statements shown below retrieve name, the name of the sender, and who, the name of the recipient of the card, from the query string.)
form$(query_string$, "name") form$(query_string$, "who")
Finally, the script produces the three possible greeting cards. Lines 1000-4000 use the form$ function to insert the names provided by the user into the greeting card.
Click here to view lines 1000 through 4000 of the script.
When a user accesses a script, the following actions are performed. (To access the sample script and follow the actions listed below, click here.)
http://www.webserver.com/scripts/card.bas
The server relays the request message to the BASIC interpreter, which invokes the script CARD.BAS again. This time, the script skips the line that returns the static web page (line 12) and instead generates a dynamic page displaying one of three cards and the arguments of two query strings: "who" and "name" (lines 510-3200). The form$ function retrieves the arguments from the query string (line 510).
Click here to view the response page displayed on the client platform
Click on the following links to view tables that briefly describe the BASIC statements supported by the BASIC interpreter NLM. For detailed information about these statements, consult a text that describes Dartmouth BASIC.