Please enable JavaScript to view this site.

When A-Shell launches, it executes the command line "cgicmd" which might be implemented something like the following:

:R

log bas:

run cgitst

$0

Finally, our program CGITST.BAS might look something like this:

program CGITST,1.0(100)

!---------------------------------------------------------------------

! Sample program used within a CGI script

! Note that we are expecting the form parameters to have been passed 

! to us in stdin (using the POST method). We'll pick them up with

! cgiutl. The output page is stored in cgitst.htm in the current 

! directory; it contains "variables" for the form parameters, which we

! substitute in using cgiutl. 

!---------------------------------------------------------------------

 

map1 PARAMETERS               ! parameters we expect to be passed by form

map2 NAME,S,60

map2 ZIP,S,5

map2 AGE,S,10            ! e.g. "11-30"

map2 COMMENTS,S,500

map1 CGIUTL'PARMS

map2 STATUS,F

 

! test if we are in cgi mode (-cgi switch used)

xcall CGIUTL,0,STATUS

if STATUS = 0 print "Not running in CGI mode" : end

! retrieve parameters

xcall CGIUTL,2,"name",NAME,STATUS

xcall CGIUTL,2,"zip",ZIP,STATUS

xcall CGIUTL,2,"age",AGE,STATUS

xcall CGIUTL,2,"comments",COMMENTS,STATUS

! now build new web page just displaying these parameters

! (using the template file CGITST.HTM)

xcall cgiutl,3,"cgitst.htm", STATUS, &

"$NAME="+NAME, &

"$ZIP="+ZIP, &

"$AGE="+AGE, &

"$COMMENTS="+COMMENTS

! finally, just end

end

 

The template file for the output web page might look like the following. Note that we don’t have to use this template approach. We can also use the CGIUTL opcode 4 to build the web page from scratch. But this approach allows you to design your web page in another tool, then just modify it to specify suitable fill-in variable names for the data you want to merge in.

content-type: text/html

 

<HTML>

<HEAD>

<TITLE> Sample CGI-generated web page </TITLE>

</HEAD>

<BODY>

<H1> Here is the information you passed in the previous form: </H1>

<P></P>

<P>Name = $NAME</P>

<P>Zip = $ZIP</P>

<P>Age = $AGE</P>

<P>Comments = $COMMENTS</P>

</BODY>

</HTML>

The above sample program doesn’t do anything useful, other than just read in the data input into the form, parse it out, and then display that data on a new web page. However, it should be easy to extend this technique to do something useful.

Created with Help+Manual 9 and styled with Premium Pack Version 5 © by EC Software