switch to italian language
Giovanni's logo
About Giovanni's Boats CGI Demo

This demo is in library CGIDEV2. It's made of three RPG ILE programs:
BOATSCH0, BOATSCH1, and BOATSCH2

1. BOATSCH0

Program BOATSCH0 is activated by HTML member DEMOMENU in source file DEMOHTML when the following button is pressed

boats demo
Program flow
The main job of this program is to write the HTML which will be input to program BOATSCH1 (boat search form), setting up the background color selected by the web user and other related colors used in the body of the HTML.
  • Receive the input string (subprocedure zhbGetInput)
  • Parse the input string into program variables (subprocedure zhbGetVar)
  • Load skeleton output html member BOATSCH0 in CGIDEV2/DEMOHTML (subprocedure GetHtml)
  • Get server's protocol for later html output display (subprocedure getEnv)
  • Set html output variables
    • for the <FORM> hidden input fields related to the background color and the national language desired
    • for the HTML <BODY parameters>
    and write out html output section top (the first part of the html script) using subprocedure wrtSection
  • The selection list (boat) Type was designed to be dynamic (generated from a database file). To provide this, database file cgidev2/boatTypes is used. This file is opened the first time this program runs, and is never closed, in order to provide best performance.
    A routine would read the records of this file and for each record would write section typsltrow after setting the appropriate output variables.
    At the end of the file, it would write section typsltend which contains the following part of the html script.
  • Last, the program would
    • write html section endhtml (after setting its output variables, including the response time)
    • send the html output buffer (by writing the pseudo section *fini
    • return leaving the LR indicator off, to provide more performance the next time it is called.
Note. This same technique of generating output HTML with variable background, links and texts colors is adopted for the other two programs of this demo, though it is not mentioned in their program flows.

2. BOATSCH1

The html issued by program BOATSCH0 contains a form with a button

When the user presses that button, program BOATSCH1 (which is mentioned in the action of the form) is invoked.

The following input string is made available to the program: (the *** stay for the user inputs)

lng=*** &bckgnd=*** &boatnbr=0 &type=*** &maker=*** &units=*** &minlen=*** &maxlen=*** &minpri=*** &maxpri=*** &city=*** &state=*** &country=*** &lstbrd=***
Program flow
  • Receive the input string (subprocedure zhbGetInput)
  • Parse the input string into program variables (subprocedure zhbGetVar)
  • Load skeleton output html member BOATSCH1 in CGIDEV2/DEMOHTML (subprocedure GetHtml)
  • Get server's protocol for later html output display (subprocedure getEnv)
  • Set html output variables
    • for the <FORM>s hidden input fields related to the background color and the national language desired
    • for the HTML <BODY parameters>
    • for the user-specified search criteria
    and write out html output section top (the first part of the html script) using subprocedure wrtSection
  • If the first time through, override and open database file cgidev2/boatsale containing the boats catalog.
    Note that this file is never closed, in order to provide the best performance.
  • Position the file to the next boat not yet listed (input field boatnbr is used for that). This input field contains 0 when the program is called through the html output from BOATSCH0. On the other site, when the program is called by pressing the button Show nnn more, this input field contains the serial number of the last boat listed.
  • Read the database file to find how many boats match the search criteria. Write the html output section howmany and, if more than 30 boats matching, the html output session 30more
  • Write the html output section tablestr which defines the start of a html table
  • Set again at the starting database record and read through until maximum 30 boats matching the search criteria are found.
    For each such record, set the variables, and write html output section tablerow showing boat length, make, type, year built, price, and city where located.
    However, this table row is not that simple, as it carries information able to activate CGI program BOATSCH2, the one that displays boat detailed information along with images and boat dependent html text.
    1. It contains a link to program BOATSCH2, along with a string that this program should receive in order to show a single boat. The link, before variable substitution, is
         <a href="/cgidev2p/boatsch2.pgm? serno=/%bnbr%/">
      where /%bnbr%/ will be replaced by the serial number of the boat
    2. It also contains the following checkbox
         <input type="checkbox" name="serno" value="/%bnbr%/">
      When the user presses the button Show these vessels, program BOATSCH2 (mentioned in the action of the <form >) will be invoked and will receive a string containing both the hidden fields (such as national language and background color) and the values of the checkboxes checked-in.
      As an example, the input string could be
         lng= &bckgnd=white &serno=0008745 &serno=0009784 &serno=0012509
      if the user selected three boats.
  • When no more matches, or 30 matches found, write html output section tablend which ends the html table
  • If at least one row in the table, write html output section foundsome containing the submit button Show these vessels. Please note that the action of this submit button (call program BOATSCH2) is defined in the action of the <form >, up in the output skeleton html
  • If more than 30 matches found, write html output section showmore which allows to relink to program BOATSCH1 passing the same values for search criteria along with the boat number it should start from
  • Finally, the program would
    • write html section endhtml (after setting its output variables, including the response time)
    • send the html output buffer (by writing the pseudo section *fini
    • return leaving the LR indicator off, to provide more performance the next time it is called.

3. BOATSCH2

Program BOATSCH2 is activated by HTML output from program BOATSCH1 when the web user takes one of the following actions

  1. User decides to display a single boat by clicking on the link displayed in a table row. In a case like this the string sent to program BOATSCH2 looks like
       lng=&bckgnd=white&serno=0008745
  2. User decides to display more than one boat by clicking on some table row check buttons, and clicking on the button Show these vessels. In a case like this the string sent to program BOATSCH2 looks like
       lng= &bckgnd=white &serno=0008745 &serno=0009784 &serno=0012509
Program flow
  • Receive the input string (subprocedure zhbGetInput)
  • Parse the input string into program variables (subprocedure zhbGetVar)
  • Load skeleton output html member BOATSCH2 in CGIDEV2/DEMOHTML (subprocedure GetHtml)
  • Get server's protocol for later html output display (subprocedure getEnv)
  • Read skeleton output html mbr BOATSCH2 in CGIDEV2/DEMOHTML (subprocedure GetHtml)
  • If the first time through override and open database file cgidev2/boatsale1 containing the boats ordered by boat number.
    Note that this file is never closed, in order to provide the best performance.
  • Set html output variables and write out html output section top (html start) (subprocedure WrtSection)
  • For each occurrence of the variable serno (boat serial number) in the input string, perform the following
    1. Retrieve boat data (GIF, boat length, make, etc.) chaining corresponding record in file BOATSALE1
    2. Write output html output section found which contains the boat data and the boat image
    3. Provide "boat dependent html text" (features, link to other pictures etc.) As boat dependent html cannot be in the skeleton html output, boat dependent html texts are maintained instead in members of file CGIDEV2/BOATTXTS. Skeleton output html member BOATSCH2, on the other way, contains a section named text with just a single variable, named /%text%/. This is how the program moves the boat dependent html into the skeleton html member:
      • Overrides file BOATTXTS to the member associated to the boat serial number
      • Opens file BOATTXTS
      • reads records; for each record substitutes variable /%text%/. and writes section text
      • on end-of-file, closes file BOATTXTS and removes the override
  • When all requests processed:
    • write html section endhtml (after setting its output variables, including the response time)
    • send the html output buffer (by writing the pseudo section *fini
    • return leaving the LR indicator off, to provide more performance the next time it is called.