Oscars Sample

The first program, oscars, is designed to return the names of actors and actresses who won Oscar awards in a specified year. Notice the definition of external form items in the Working-Storage section of this program. Notice also that the ACCEPT statement in the main logic section ACCEPTs these external form items, and that the DISPLAY statement defines the HTML templates to be used: "HTML-header-form," "HTML-footer-form," and "body-para." The contents of these templates follows.

identification division.
program-id. oscars.
remarks.
working-storage section.
01  cgi-form       is external-form.
    05 y2004       pic x(5) is identified by "y2004".
    05 y2003       pic x(5) is identified by "y2003".
    05 y2002       pic x(5) is identified by "y2002".
01  cgi-form-table redefines cgi-form.
    05  cgi-year   pic x(5) occurs 5 times.
01  html-header-form is external-form identified by "header".
    05  opening-message    pic x(40).
01  html-body-form is external-form identified by "body".
    05  ryear      pic x(5).
    05  html-oscar-info.
        10  rmovie       pic x(25).
        10  ractor       pic x(42).
        10  ractress     pic x(42).
01  html-footer-form is external-form identified by "footer".
    05  closing-message  pic x(40).
01  movie-values.
     05  2004-oscar.
        10 movie     pic x(25) value "THE LORD OF THE RINGS".
        10 actor     pic x(42) value "Sean Penn MYSTIC RIVER".
        10 actress   pic x(42) value "Charlize Theron MONSTER".
     05  2003-oscar.
        10 movie     pic x(25) value "CHICAGO".
        10 actor     pic x(42) value "Adrien Brody THE PIANIST".
        10 actress   pic x(42) value "Nicole Kidman THE HOURS".
     05  2002-oscar.
        10 movie     pic x(25) value "A BEAUTIFUL MIND".
        10 actor     pic x(42) value "Halle Berry MONSTER'S BALL".
        10 actress  pic x(42) value "Denzel Washington TRAINING DAY".
01  movie-table redefines movie-values occurs 5 times.
     05  oscar-winners.
         10  best-movie   pic x(25).
         10  best-actor   pic x(42).
         10  best-actress pic x(42).
01  various-counters.
     05 idx-1              pic 99 value 1.
procedure division.
main-logic.
accept cgi-form.
     if cgi-form = space
          move "You did not select any years!" to opening-message
          display html-header-form
          move "Back up and try again." to closing-message
     else
          move "Acucorp CGI in action." to opening-message
          display html-header-form
          perform display-body-para
          move "THE END." to closing-message
     end-if.
     display html-footer-form.
     stop run.
display-body-para.
     perform varying idx-1 from 1 by 1 until idx-1 > 12
          if cgi-year(idx-1) = space
               continue
          else
               move cgi-year(idx-1) to ryear
               move movie-table(idx-1) to html-oscar-info
               display html-body-form
          end-if
     end-perform.

Header.htm

<HTML><HEAD><TITLE>ACUCOBOL-GT CGI Header</TITLE></HEAD>
<BODY>
<H2>%%opening-message%%</H2>
<CENTER><H1>Oscar Winners</H1>
<HR>
<TABLE border cellspacing=0 cellpadding=5>
<TR>
<TH colspan=4 align=center>Your Selections</TH>
</TR>
<TR align=center>
<TH>Year</TH>
<TH>Best Movie</TH>
<TH>Best Actor</TH>
<TH>Best Actress</TH>
</TR>

Footer.htm

</TABLE>
</CENTER>
<H2>%%closing-message%%</H2>
<HR>
<P>The information you requested was processed by the ACUCOBOL-GT CGI program.
<BR>Following the CGI standard, ACUCOBOL-GT was able to send 
<BR>the requested data items to the appropriate templates and
<BR>return the completed HTML document back to you.</P>
</BODY></HTML>

Body.htm

<TR align=center>
<TD>%%ryear%%</TD>
<TD>%%rmovie%%</TD>
<TD>%%ractor%%</TD>
<TD>%%ractress%%</TD>
</TR>

Oscar.htm

<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<META NAME="Generator" CONTENT="Microsoft Word 97">
<TITLE>ACUCOBOL-GT CGI Example</TITLE>
<META NAME="Template" CONTENT="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
</HEAD>
<BODY LINK="#0000ff" VLINK="#800080">
<H2>ACUCOBOL-GT CGI Example using ACUCOBOL-GT.</H2>
<H3>This example shows how easily you can use ACUCOBOL-GT to act as a CGI program. 
<BR>User input is transferred from the following HTML page to a ACUCOBOL-GT program running <BR>
on the web server. The appropriate output is returned.</H3>
<P><HR></P>
<H1 ALIGN="CENTER">Oscar Trivia</H1>
<P>Select a year(s)and press the Submit Query button. <BR>
The Best Picture, Best Actor and Best Actress for each year selected will be returned. </P>
<FORM ACTION="http://your_server_name/Scripts/oscars.acu" METHOD="post">
<P>Year: </P>
<P>
<INPUT TYPE="checkbox" NAME="y2004" VALUE="2004">
2004 
<INPUT TYPE="checkbox" NAME="y2003" VALUE="2003">
2003 
<INPUT TYPE="checkbox" NAME="y2002" VALUE="2002">
2002 
<P>
<INPUT TYPE="submit"  VALUE="Submit Query" >
</P></FORM></BODY>
</HTML>